Posts

Showing posts from September, 2013

python - what went wrong with my get and set properties? -

please need help. code pycharm , keeps showing me unresolved reference 'model'. parameter 'model' value not used , getter signature should (self). please how around this. class productobject: def __init__(self, product, brand, car, model, year): self.product = product self.brand = brand self.car = car self.model = model self.year = year def set_product(self, product): self.product = product.capitalize() def get_product(self): return self.product product = property(get_product, set_product) def set_brand(self, brand): self.brand = brand.title() def get_brand(self): return self.brand brand = property(get_brand, set_brand) def set_car(self, car): self.car = car.title() def get_car(self): return self.car car = property(get_car, set_car) def set_model(self): self.model = model.title() def get_model(self, model):

python - pandas 'chunked' save to_csv of pivoted table on very large dataframes -

my original file pivot large memory: tbl = pd.read_csv('tbl_sale_items.csv',sep=';',dtype={'saleid': np.str, 'upc': np.str}) tbl.info() <class 'pandas.core.frame.dataframe'> rangeindex: 18570726 entries, 0 18570725 data columns (total 2 columns): saleid object upc object dtypes: object(2) memory usage: 283.4+ mb the unique upcs around 40000 , saleid row around million+. the file looks like: saleid upc 0 155_02127453_20090616_135212_0021 02317639000000 1 155_02127453_20090616_135212_0021 00000000000888 2 155_01605733_20090616_135221_0016 00264850000000 3 155_01072401_20090616_135224_0010 02316877000000 4 155_01072401_20090616_135224_0010 05051969277205 it represents 1 customer (saleid) , items he/she got (upc of item) i correctly pivot table using solution . 02317639000000 00000000000888 00264850000000 02316877000000 155_0212745

sql - Postgres Update multiple rows -

i need update multiple rows in table. i have table customer , contact i need update customer linked contact in contact table has column city @ value. can rows need query select cus.id, con.city customer cus, contact con cus.contacts_id=con.id , con.city="myvalue" i know how update 1 table not understand how update table when rows looked different table. firstly, please not use old joins (from comma separated tables). secondly, here go: update customer set whatever = 'whatever value' contacts_id in ( select id contact city="myvalue" )

jquery - wordpress json data with owl carousel -

following code working perfect , showing result. when add owl carousal show result slider. single line div not slide show. data getting json wordpress plugin. $(document).ready(function(){ $.getjson("./blog/?json=1",function(data) { //console.log(data); (var i=0;i<data.posts.length;++i){ if (data.posts[i].date.substring(6, 7) == 01){ var mymonth = "jan"}; if (data.posts[i].date.substring(6, 7) == 02){ var mymonth = "feb"}; if (data.posts[i].date.substring(6, 7) == 03){ var mymonth = "mar"}; if (data.posts[i].date.substring(6, 7) == 04){ var mymonth = "apr"}; if (data.posts[i].date.substring(6, 7) == 05){ var mymonth = "may"}; if (data.posts[i].date.substring(6, 7) == 06){ var mymonth = "jun"}; if (data.posts[i].date.substring(6, 7) == 07){ var mymonth = "jul"}; if (data.posts[i].date

javascript - Append the options to select box only once instead of multiple times -

i have button called "add new menu" in html page , onclick opening modal contain form , <select></select> elements. like this. <button class="btn btn-success" onclick="add_menu()"><i class="glyphicon glyphicon-plus"></i> add new menu</button> here modal. <div class="modal fade" id="modal_form" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button> <h3 class="modal-title">menu form</h3> </div> <div class="modal-body form"> <form id=&qu

c# - Bundling css even if using @import -

i'm developing application in c# , asp.net mvc. have various css files 1 called base.css import other css files using @import rule as: @import url('base.css'); then bundle css files minimise them as: bundles.add(new stylebundle("~/content/css").include( "~/content/bootstrap.css", "~/content/site.css")); ... more css files so question have bundle base.css if i'm importing different css? because if don't bunble styling doesn't work required. because mvc bundler creates entirely new file in potentially different location (see full path in bundle name), location of import statements becomes inaccurate. what can instead create separate css file (or static declaration on _layout page includes import statements), , include outside of bundle.

python - Visualizing pivot table with 3 variables via 2D plot -

i have pivot table of 3 variables: a , b , , c . want plot pivot table in following 2d format using python. c 30 | x x x 20 | x x x x 10 | x x x x x _______________________ b 1 2 3 4 1 2 3 4 1 2 3 4 1024 2048 4096 to above plot, want add plot of pivot table same a , b values different variable called d . values of d must connected lines within group of b values, i.e., 1 , 2 , 3 ,and 4 same value of a .

javascript - Setting window.pageYOffset in Firefox doing nothing? -

i'm using recent version of firefox. i'm trying window scroll position before submitting form. in html head of page there's code: if (sessionstorage.top !== null) { window.pageyoffset = sessionstorage.top; } and later validation function called has following line in it: sessionstorage.top = window.pageyoffset; since function submits form page automatically reloaded. i've verified validation function called, executing way through including line above. i've verified code in html head being executed (including inside if statement - sessionstorage.top not null. i've verified both sessionstorage.top , window.pageyoffset set 630. yet window stays @ position 0 (zero). i've tried setting window.pageyoffset directly 630 , nothing. page stays @ topmost (default) position. what missing? because readonly? use window.scrolltop = offsetvalue; set scroll position.

python - virtualenv: "cannot import name 'Flask'" -

this question has answer here: importing installed package script raises “attributeerror: module has no attribute” or “importerror: cannot import name” 1 answer maybe i'm doing wrong, after 1 hour of staring @ code i'm not getting smarter. my problem virtualenv. set venv2 , venv3 folders in home-directory. installed flask on both of them, alongside other packages. the problem can't run helloworld-example flask. from flask import flask app = flask(__name__) @app.route('/') def hello_world(): return 'hello world' example venv2: (venv2) #( 7.09.16@14:11 )( dun@arch64l ):~ python /home/dun/venv2/bin/python (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~ python3 /usr/bin/python3 (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~ pip /home/dun/venv2/bin/pip (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~ cd _workspace/py/flask (venv2) #( 7.09

html - Positioning horizontal menu using flexbox -

i trying fixed menu using flexbox. in navigation bar created 2 divs. first should contain logo, , second menu(with display:flex property). i've got problem, when want postion li element of menu. want horizontal menu, when add justify-content:space-between first element should situated in left edge of menu's div has small margin , don't know why. https://jsfiddle.net/4lmu08yc/ header { height:100vh; background-color:yellow; width:100vw; max-width:100%; } .navbar { width:100vw; background-color:grey; height:7vh; max-width:100%; position:fixed; border-bottom:5px solid white; z-index:2; } .flex_row { display:flex; flex-direction:row; } .container{ height:100%; width:100vw; max-width:100%; background-color:green; display:flex; } #logo { height:100%; background-color:white; flex-grow:1; } #menu { height:100%; background-color:

performance - Why my Ionic CLI commands are a lot slower than Cordova? -

i'm using ionic 2.0.0-beta.37 , cordova 6.2.0 , node 6.2.0 on osx 10.11.4 cordova platform list | time ionic platform list real 0m19.449s | real 1m16.809s user 0m0.890s | user 0m2.711s sys 0m0.166s | sys 0m0.685s cordova plugin list | ionic plugin list real 0m0.587s | real 0m41.768s user 0m0.503s | user 0m2.362s sys 0m0.055s | sys 0m0.891s why ionic cli slower? i facing speed issue when ionic serve, tried disabling live reload, not helpful. i found this answer on ionic forum, notice speed improvement while doing ionic serve try doing npm rebuild node-sass

sql server - Malfunction of data copy from excel to Sql using BulkCopy (vb.net) -

i'm searching reason why importation excel sql table not working (via vb.net) the excel file in input contains 1300 rows , 12 columns. 5 last columns contains prices. after importation, table if filled excel data except 2 last "price" columns data 'null'. strange thing "price" columns in sql destination table formatted same type (decimal(18,2)), in excel file. copy, use sqlbulkcopy , wonder if function not limited. here's code: dim excelconnection new system.data.oledb.oledbconnection("provider=microsoft.ace.oledb.12.0;data source=" & ftransp & ";extended properties=""excel 12.0 xml;hdr=yes""") excelconnection.open() dim requeteexceltransp string = "select * [excelcetup$]" dim objcmdselect oledbcommand = new oledbcommand(requeteexceltransp, excelconnection) dim objdr oledbdatareader using bulkcopy sqlbulkcopy = new sqlbulkcopy(conn

java - why chrome driver is not working in @Before? -

i have simple code public class pageavailable { @test public void test() { system.setproperty("webdriver.chrome.driver", "c:/users/jars/chromedriver_win32/chromedriver.exe"); webdriver driver = new chromedriver(); driver.get("https://....net"); system.out.println(driver.gettitle()); driver.close(); }} above code working fine want code in more structure way public class pageavailable { webdriver driver = new chromedriver(); @before public void be(){ system.setproperty("webdriver.chrome.driver", "c:/users/jars/chromedriver_win32/chromedriver.exe"); driver.get("....net"); } @test public void test() { driver.get("https://...net"); system.out.println(driver.gettitle()); } @after public void af(){ driver.close(); }} i getting following error after executing above code ja

User level permissions on Amazon s3 on Public read URL -

i have uploaded few files on amazon s3 cannedchannellist publicread. remember file has public read permissions, not whole bucket or folder. , user able access file using given url. here 1 security concern user can manipulate given url access other files in same or different folder. there way user need send authentication key while hitting url, while reading file , how can let users know authentication key have use? i've read iam users uploading file , that. want authentication while reading data using url. data uploaded single admin user, however, users sent data server , using single admin user uploading of on s3. this policy using admin user. if(isbucketexist(bucketname)){ statement allowpublicreadstatement = new statement(statement.effect.allow) .withprincipals(principal.allusers) .withactions(s3actions.getobject) .withresources(new s3objectresource(bucketname, "*")

c++ - Is it okay to inherit implementation from STL containers, rather than delegate? -

i have class adapts std::vector model container of domain-specific objects. want expose of std::vector api user, he/she may use familiar methods (size, clear, at, etc...) , standard algorithms on container. seems reoccurring pattern me in designs: class mycontainer : public std::vector<myobject> { public: // redeclare container traits: value_type, iterator, etc... // domain-specific constructors // (more useful user std::vector ones...) // add few domain-specific helper methods... // perhaps modify or hide few methods (domain-related) }; i'm aware of practice of preferring composition inheritance when reusing class implementation -- there's gotta limit! if delegate std::vector, there (by count) 32 forwarding functions! so questions are... bad inherit implementation in such cases? risks? there safer way can implement without typing? heretic using implementation inheritance? :) edit: what making clear user should not use mycontainer via std::

elasticsearch - Logstash json filter for only one level -

i use following filters configuration: filter { if [type] == "client-log" { grok { match => { "message" => "%{combinedapachelog}" } } urldecode{ field => "request" } mutate { gsub => [ "request", '/log/', '' ] } json { source => "request" } } } it works fine when request 1 level json object. if gets more 1 level logstash getting parse error. advice? request example: { session_id: "123", message: { id: 1221 //.... } //.... } error: {:timestamp=>"2016-09-07t15:53:34.712000+0100", :message=>"error parsing json", :source=>"request", :raw=>"{\"session_id\":\"8d078da0-74f9-11e6-8d31-6925e76dde0e\",\"level\":\"debug\",\"methodname\":\"fetchexternaldata\",\"class\":\"fetchex

sql - Roll directories up to parent -

Image
is there way roll data looks this: what looking this: y:\data\fs02-v\aetna\etl | data, development files so rows 2 , 3 being children of row 1 should roll parent , parent should show file types contained. working in sql server , code produces source table: select [mcl].[category description] category , [sf].[directory] directory , convert(bigint, [sf].[length]) filesize , (select max([id]) [dbo].[split](right([sf].[directory],len([sf].[directory])-1),'\')) [levelsfromroot] [dbo].[fs02v_sourcefiles] [sf] inner join [dbo].[extensions] [e] on [sf].[extension] = [e].[extension] inner join [dbo].[mastercategorylookup] [mcl] on [mcl].categoryid = [e].category order [sf].[directory] table def: create table [dbo].[fs02v_sourcefiles]( [length] [float] null, [directory] [nvarchar](255) null, [extension] [nvarchar](255) null, [type] [nvarchar](max) null

c++ - template which takes a pack of type T -

i have following minimal code fragment compiles , executes expected: template < class t, t... chrs> struct mystring { static auto c_str() { static char str[] = {chrs..., 0}; return str; } }; template <class t, t... chrs> auto operator""_t() { return mystring<t, chrs...>(); } int main() { auto x = "hallo"_t ; std::cout << x.c_str() << std::endl; } question: is possible write template mystring in way excepts: auto x = mystring<'a','b','c'>(); but also auto x = mystring< 1,2,3> (); or other type. i have no idea how write ( pseudo code ): template < t ... chrs> // how define t here? struct mystring { } also following not allowed: template <typename t, t ...chrs > struct mystring<t...chrs> {}; the same way you're doing right now. except instead of using t , t template parameter, use char directly: tem

jquery - When I pick default dropdown value with javascript, it doesn't trigger change -

i have textfield , date textfield. trying connect them javascript, encounter problem. script is: <script> $("#soldate").change(function () { if ($(this).val().trim() == '') { $("#casestatus").val('in progress'); $("#solvedby").val('pick option'); $("#solvedby").change(); } else if ($(this).val().trim() != '' && $("#solvedby").val().trim() == '') { $("#casestatus").val('solved'); $("#solvedby").val('please, pick issue solver'); $("#solvedby").change(); } }); </script> when date picked calendar, should set value 'please, pick issue solver'. works perfectly. then, if entered date incidentally, sho

javascript - symlink causing 2 versions of react -

i have project bunch of sub custom npm modules being loaded in - work in submodules publish them private npm repository , pull them main platform of project use. speed dev time, have been symlinking sub module's dist (transpiled publish) folder main project building. other modules, has been ok, current module seems loading 2 copies of react. clear, error message: bundle.js:29585 uncaught (in promise) error: removecomponentasreffrom(...): reactowner can have refs. might removing ref component not created inside component's render method, or have multiple copies of react loaded what confusing doing npm ls react shows me this: └── react@15.3.0 so looks there 1 version. also, if delete symlink , npm module private repo (with exact same code), not have error. main platform , sub repo both have react dep, have done method other sub repos have react dep , have had no issues before. using webpack bundle well, don't know if part of issue. has run this?

javascript - AngularJS: Updating table contents from Select option -

currently, trying more acquainted angularjs , single page applications. feel making headway, find empowering, since found wpf relatively confusing. however, feel having grave misunderstanding of angularjs supposed do. frame question more simply, have constructed basic example website can practice. the website formatted menu soda products user can select different vendors, , available sizes view price of product. example , prices , sizes (ie, data displayed on web page) not meant correct. meant correct method , format displaying such information. my problem cannot seem access scope's "selectedvendor" ng-model template url (or @ least not "traditionally" i.e., typing name). breaks code need list of available sizes vendor has been selected. i looked through several other similar questions, answers provided seemed point ng-repeat option being offending party. sorry if duplicate. here code: index.html: <!doctype html> <html> <head

javascript - Fill a container with content using React.JS -

i have container element, react component, specific height. have api returns blocks of contents of variable length, based on requested id. <contents/> i want request new block of content api until container overflowing. my code works, rerenders content blocks , adds 1 in each render, until container full. seems bad approach. class contents extends react.component { constructor() { super(); this.state = { numelements: 0 }; } render() { const elements = []; for(let = 0; < this.state.numelements; i++) { elements.push(this._getelementcontents(i)); } return(<div id="contents"> {elements.map(element => element)} </div>); } componentdidmount() { // start 'filling loop' this._addelement(); } componentdidupdate() { // keep adding stuff until container full if(document.getelemen

angularjs - ng-click breaks the App if triggered by clikcing element from Shadow Dom -

the idea keep svgs in shadow dom , insert them 'use' tag. issue in ie11 when adding ng-click elements encapsulating svgs. <a ng-href="#/settings/profile"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon--medium" name="cog"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#cog"></use> </svg> </a> same happens on clicking tag or element attached ng-click. after problem occurs, ui stops responding. hard page reload fixes issue. observed in ie only. chrome works fine. any idea can be? try add pointer-events: none; svg elements

javascript - ORIGINAL EXCEPTION: No provider for Router! angular 2 RC5 -

can't use this.router.navigate. this my: app.module.ts import {ngmodule, ngmodulemetadatatype} '@angular/core'; import { browsermodule } '@angular/platform-browser'; import {formsmodule} '@angular/forms'; import { httpmodule } '@angular/http'; ... import {routing} "./app.routing"; import {entry} "./entry.component"; imports: [ browsermodule, formsmodule, routing, httpmodule, ], test component import { component } '@angular/core'; import {httpclient} "./httpclient.component"; import {router} "@angular/router-deprecated"; @component({ templateurl: 'templates/entry.html' }) export class entry { ... constructor(head:headercomponent, private httpclient: httpclient, private router: router) { this.httpclient = httpclient; } nav_test(){ this.router.navigate(['search']);

Vagrant mount folder twice in df command -

here's df result: vagrant@precise64:~$ df -h filesystem size used avail use% mounted on /dev/mapper/precise64-root 78g 3.7g 70g 6% / udev 172m 4.0k 172m 1% /dev tmpfs 73m 296k 73m 1% /run none 5.0m 0 5.0m 0% /run/lock none 182m 0 182m 0% /run/shm cgroup 182m 0 182m 0% /sys/fs/cgroup /dev/sda1 228m 53m 164m 25% /boot vagrant 233g 82g 152g 35% /vagrant vagrant 233g 82g 152g 35% /vagrant srv_website 233g 82g 152g 35% /srv/website srv_website 233g 82g 152g 35% /srv/website key mount info : config.vm.synced_folder "vagrant_data" ,"/srv/website" it's odd /vagrant mounted , mount twice, /srv/website vagrant 233g 82g 152g 35% /vagrant vagrant

hibernate - Camel JPA 'consumeDelete' when called? -

so i'm using camel-jpa , set consumedelete property true consumed entity gets removed, after consumed. i'd know is: when entity removed during chain-process? is there specific point, entity removed? there specific step in route, happens? its removed when message completed being routed, eg not before routing, or during routing. in other words happens automatic last step in route, if message processed successfully. if have error of sorts not handled, record not deleted, camel can try again. can use camel error handling handle error message regarded being processed jpa deletes record.

c# - Create WPF Vertical icon navigation -

Image
enter code here i'm looking create wpf interface similar image. wpf controls need use achieve this? <window x:class="example1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:example1" mc:ignorable="d" title="mainwindow" height="350" width="525"> <grid background="#fffdfdfd"> <grid.columndefinitions> <columndefinition width="200"></columndefinition> </grid.columndefinitions> <grid background="#ff0052f0" horizontalalignment="left" width="50"> </grid> </grid> to answer quest

linux - ansible file and directory permissions -

trying ansible file/directory permissions work. in ansible create user: user: name=testuser shell=/sbin/nologin uid=1234 comment="test user" then try change ownership of file directory: file: path=/etc/myfile state=directory owner=testuser group=testuser mode=0644 recurse=yes i have tried setting facl file: acl: name: /var/log/audit/audit.log entity: filebeat etype: user permissions: rx state: present when observing file permissions , facl, appear set correctly. if change shell of test user , login, discover don't have permissions ansible presumably set. keep getting "permission denied" message. if understand mean, "permission denied" when try accessing directory content, e.g. running ls -l /etc/myfile . right *nix behaviour because setted acces permission mode=0644 . about directories, execute bit allows affected user enter directory, , access files , directories inside. so, allow testuser g

python - Correct way to gracefully exit code prematurely from any section -

i have bunch of threads, classes, methods, , loops. in each level have pass, check, , handle global variable causes section of code exit before completing it's task if user wants exit program early. every time-dependent section literally wrapped in if not quit_now(): (or similar). cannot code-fu - there better way?

PHP doesn't send data to MySQL -

have problem couldn't find solution for, though searched through many sources (and questions here too). so, here is. php-code below suppose collect data html-form , send local wamp-server. but, though final check shows me "success!", no new rows in database's table found, stays empty. names correct, commands (as see it) too, don't know what's wrong. hope guys me. ^^ //check if user submited form if (isset($_post['submit'])) { //check if filled if (empty($_post['itemname']) || empty($_post['itempic']) || empty($_post['itemprice']) || empty($_post['itemprovider'])) { echo '<script>alert ("fill out form please!")</script>'; } else { $conn = new mysqli('localhost:3306', 'root', '', 'goods-review'); //check if connection established if (mysqli_connect_errno()) { exit('connect failed: ' . mysqli

testing - How to use 'OR' with Mocha / Chai -

i trying test if text has text1 or text2. like: expect(text).to.contain.text1 || expect(text).to.contain.text2. there not .or any doesn't work because .text() doesn't allow me do: expect(text).to.contain.any.text(text1,text2) no, doesn't work: expect(text).to.contain.text1 || expect(text).to.contain.text2 . any idea ? thanks. i think can use .oneof(list) or .satisfy(function) . for example, expect(text).to.be.oneof(['hello', 'world']); or expect(text).to.satisfy(function (t) { return t === 'hello' || t === 'world'; });

python - How to get a max string length in nested lists -

they follow question earlier post (re printing table list of lists) i'm trying t string max value of following nested list: tabledata = [['apples', 'oranges', 'cherries', 'banana'], ['alice', 'bob', 'carol', 'david'], ['dogs', 'cats', 'moose', 'goose']] in tabledata: print(len(max(i))) which gives me 7, 5, 5. "cherries" 8 what missing here? thanks. you've done length of maximum word . gives wrong answer because words ordered lexicographically : >>> 'oranges' > 'cherries' true what wanted maximum of lengths of words : max(len(word) word in i) or equivalently: len(max(i, key=len))

ssl - Determine Diffie-Hellman "Parameters" Length for a TLS handshake in Java -

i'd make https connection server and, if i'm using non-ephemeral dh key exchange, i'd know parameters connection. actually, don't care if it's ephemeral or not. what i'm looking ability make connection , warn if connection using "weak" dh parameters. can check @ connection-time? or set of dh parameters (or, more specifically, length of parameters, in bits) defined cipher suite itself? for example, qualys community thread has illustration of cipher suites ssllabs considers "weak" (well, considers them weak... have public tool complains them): https://community.qualys.com/thread/14821 they mention e.g. tls_dhe_rsa_with_aes_256_gcm_sha384 cipher suite 0x9f , mention dh parameters. parameters' parameters baked-into cipher suite (meaning always 1024-bit) or configuration of server makes cipher suites weak due specific dh parameter choice? in either case, i'd able sniff information connection if @ possible. know if can done,

python - SQL / Pandas equivalent -

what pandas equivalent sql query : select column1, sum(column2) a, count(distinct column3) b, sum(column2) / count(distinct column3) c table1 group column1 thanks on that!! i'm not sure sum(column2) / count(distinct column3) c part can done in same single step, can in 2 steps: demo: in [47]: df = pd.dataframe(np.random.randint(0,5,size=(15, 3)), columns=['c1','c2','c3']) in [48]: df out[48]: c1 c2 c3 0 4 0 3 1 2 3 2 2 1 2 3 3 3 3 0 4 1 0 4 5 1 1 1 6 2 3 3 7 2 2 2 8 4 0 0 9 1 1 0 10 1 3 0 11 4 3 1 12 0 0 3 13 3 1 0 14 4 3 1 in [49]: x = df.groupby('c1').agg({'c2':'sum', 'c3': 'nunique'}).reset_index().rename(columns={'c2':'a', 'c3':'b'}) in [50]: x out[50]: c1 b 0 0 0 1 1 1 7 4 2 2 8 2 3 3 4 1 4 4 6 3 in

python - Algorithm for checking diagonal in N queens algorithm -

i trying implement n- queens problem in python. need small in designing algorithm check if given position of queen check whether other queen on board present on diagonal or not. i trying design function diagonal_check(board, row, col) board n*n matrix of arrays '1' represents presence of queen , '0' represents absence. pass array , position of queen (row,col) function. function must return false if other queen present on diagonal or else return true. if me algorithm diagonal_check function. not looking specific language code. let top left corner (0,0) the down-right oriented diagonal square (row,col) col-row+7 the up-right oriented diagonal square (row,col) row+col simply check if 2 queens have same col-row+7 or row+col should tell if 2 queens on same diagonal. if still bit confused, google chessboard image.

Passing array argument to bash from php -

i trying pass array shell_exec , want access array in bash file. tried research many websites did not find proper solution it. please me out resolve issue. in advance php code $array= $countries_array; // countries array database shell_exec('sh get_countries.sh '.$array); bash file countries.sh echo $1; i have understanding of array in bash file: #!/bin/bash declare -a myarray myarray=("$@") arg in "${myarray[@]}"; echo "$arg" done but confused, how fetch $array in bash file? also passing variable, use following code: $var=shell_exec('sh get_countries.sh hello'); echo $var; bash file==> echo $1 output hello echo 'sh countries.sh '.join(' ',$data); output==> sh countries.sh a940cfb9-2abe-5835-9d69-41c0d992c38d 768bd771-359f-5da0-9f66-ccae4460f98d 778f384c-8496-56f1-96e6-4a03b2c22ff5 45ba4726-bba8-5e7b-ab62-c0e30df2e81b c8eb2a47-dc44-5439-80db-b6c7b7c1d30c c875edce-2177-55c9-bfa0-c4a

dns - Having problems creating MX records for subdomain on dreamhost. -

i have domain on dreamhost, block.com. domain points address outside of dreamhost (amazon aws). i have subdomain, us.block.com hosted on aws. subdomain not registered on dreamhost (as dreamhost doesn't allow subdomains hosted outside of dreamhost). point subdomain, i've added in couple of custom records dns records on dreamhost. since subdomain not registered on dreamhost, doesn't allow me add custom mx records. there anyway around this? if there isn't, can somehow point mail server of us.block.com of block.com without using mx records? you can little trick: domains > manage domains fully host subdomain under "web hosting" find "remove" , press it now can edit custom mx fields subdomain tested solution here

c# - MVC Ajax.error render Partial View -

while working kendo ui grid asp.net mvc finding frustrating behavior can't seem understand or find information on. have grid makes kendogrid.savechanges() request server has server side validation. if server-side validation fails, returns following result: response.statuscode = http_bad_client_request; // const int 400 return partialview("error/badrequest"); the partial view has basic html displaying error information user, , grid's datasource error callback following: function errorcallback(e) { // handles explicit ajax , kendo datasource error callbacks var content = e.responsetext || e.xhr.responsetext; // wrapper around kendo.ui.window display content core.alert.raisealert(content); } when run project in debug mode, or publish release version of project local machine e.xhr.responsetext value populated correctly i.e. contains partial view's html message. however, move production server e.xhr.responsetext contains value "bad

android - Setting FLAG_KEEP_SCREEN_ON of an activity from another activity -

i have activity calls activity(not intent,through sdk not open source). second activity mediaplayer , since don't have access code of activity , in jar file, want set flag_keep_screen_on activity other activity. intention here prevent screen turning off during play of video in mediaplayer. i'll appreciate if can me this. thanks you can't, can similar. when launch activity, use startactivityforresult. @ same time, take wakelock keeps screen on. when onactivityresult called, release wakelock.

c++ - Encrypt with AES without header -

i'm trying encrypt 16kib block aes. i tried openssl, size grew 16384 16416. looks openssl put 32b header. is there way "remove" 32b header? if matters, environment redhat 5.11. edit: tried command line tools of openssl: encryption: openssl aes-256-cbc -in text.txt -out encrypted.txt decryption: openssl aes-256-cbc -d -in encrypted.txt -out decrypted.txt also - need tool can use c++. no, did not put header . did padding . the aes block cipher 128 bit block size requires length of data being enciphered cipher block size. padding used recover original data stream length after deciphering. edit: according @jww openssl lib prepends stream 16byte header containing magic 8-byte string "salted__" , and iv, derived password

javascript - JSON: Add pointer -

i have automatially made json looks like: { "node_id_1": { "x": -87, "y": 149 }, "node_id_2": { "x": -24, "y": 50 }, "node_id_3": { "x": 55, "y": -32 } } i have problems access specific node_id x , y values. idea automatically add "id:" before e.g. "node_id_1" , flatten array. give me hint how add "id:" ? or there elegant way access ids? thank lot! best regards a possibility using es6 , if attempting do? perhaps clarify question further description , examples of code using trying access data? function clamp(value, min, max) { return math.min(math.max(value, min), max); } const jsonstring = '{"node_id_1":{"x":-87,"y":149},"node_id_2":{"x":-24,"y":50},"node_id_3":{"x":55,"y":-3

angularjs - Angular material slider how to set ticks values -

is there way using angular slider define sliding values example if have min val 0 , max val 15 possible set values user can slide list [3,4,6,9...] instead of having steps of 1 or 2? if it's not possible angular material slider there other angular module can used? you can using angular slide using stepsarray: [3,4,6,9...] here plunker that

laravel - How to make combination of two columns as a unique key? -

i have table : public function up() { schema::create('edition', function (blueprint $table) { $table->increments('id'); $table->integer('volume'); $table->text('cover')->nullable(); $table->enum('number', ['1', '2']); $table->timestamps(); }); schema::table('journal', function(blueprint $table) { $table->foreign('id_edition')->references('id')->on('edition')->ondelete('cascade')->onupdate('cascade'); }); } i wanted make combination of column volume , number unique key. example, there data "volume 1, number 1" , when user insert same combination throw error message data exist. there way can in laravel ? just include following snippet inside up() method $table->unique(['volume','number']); by having constraint set, if insert 'volume 1 ,

python - Why isn't PyCharm's autocomplete working for libraries I install? -

Image
pycharm's autocomplete isn't working installed libraries. have following code: from boto.emr.connection import emrconnection conn = emrconnection(aws_keys.access_key_id, aws_keys.secret_key) i want editor tell me methods have available me when press ctrl space . the boto library installed in environment, doesn't seem detected pycharm. how can set correctly? you've installed 3rd-party library virtualenv, pycharm doesn't know default. if nothing specified, choose system python install interpreter. need go project settings , configure interpreter point @ virtualenv. pycharm index interpreter , allow autocomplete. the virtualenv may auto-detected in dropdown menu on left. if not, click gear right, click "add local", , select /path/to/virtualenv/bin/python (or \path\to\virtualenv\scripts\python.exe on windows).

templates - How is this CSS class working when it is not listed anywhere? -

i opened adobe dreamweaver's starter template named 'email-fluid' , seems pretty straight forward other there css classes being used can't locate styles them. instance there following line of code:- `<div style="display:inline-block; max-width:50%; margin: 0 -2px; vertical-align:top; width:100%;" class="stack-column">` you see there class defined 'stack-column' class cannot found within header of document. there no links outside documents or calls bootstrap. in addition there tags (that think html) don't recognise <webversion> , <unsubscribe> . can me understand these can edit classes?

php - Laravel Asgard CMS drop down from database in create view -

i learning laravel , trying laravel based asgard cms. don't have complete knowledge of laravel stuck @ something. i have package table in database, holds - package name, price, id. i have table holds clients data - name, package, address. what want achieve when creating client, should able assign him package. want drop down package table in create view can guide me? here create view file. <div class="box-body"> <p> {!! form::normalinput('name', 'your name', $errors) !!} {!! form::normalinput('package', 'your package', $errors) !!} {!! form::normalinput('address', 'your address', $errors) !!} {!! form::normalinput('zone', 'your zone', $errors) !!} </p>

c# - System.Configuration.ConfigurationManager.AppSettings not working -

below app.config file <configuration> <appsettings> <add key="input_file" value="d:\bioen\web\newuser\dotnet\passwordgenerator\autopassword\autopassword\passwords.txt"/> <add key="location" value="sequals"/> </appsettings> </configuration> when attempt read values in program shown below, both strings null. why this? string path = system.configuration.configurationmanager.appsettings["input_file"]; string location = system.configuration.configurationmanager.appsettings["location"];

c# - What does RPC call failed mean when executing Documents.Open thru Word interop -

we getting error reports our customers comexception 0x800706be remote procedure call failed the code generating exception following one: microsoft.office.interop.word.documents.open(object& filename, object& confirmconversions, object& readonly, object& addtorecentfiles, object& passworddocument, object& passwordtemplate, object& revert, object& writepassworddocument, object& writepasswordtemplate, object& format, object& encoding, object& visible, object& openandrepair, object& documentdirection, object& noencodingdialog, object& xmltransform) i cannot find information anywhere can cause of exception code , cannot reproduce in our computers. can similar exceptions doing weird things (debugging , stopping it, hanging process, etc) word not one. does know can mean / cause of exception? edit more information. application client app running on windows 7 computer , error intermitent looks not related e

java - Bintray gradle plugin not uploading artifacts -

i using bintray gradle plugin upload java artifact on bintray. have written code example, creates package , version there not files in files directory. missing here?? bintray { user = 'user name' key = 'my key' pkg { repo = 'androids' name = 'name' licenses = ['apache-2.0'] vcsurl = 'https://github.com/bintray/gradle-bintray-plugin.git' version { name = 'version' desc = 'gradle bintray plugin 1.0 final' released = new date() vcstag = '1.3.0' attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin'] } filesspec { 'build/libs' 'standalone_files/level1' } } } i running task root project build directory not defined. when ran in module (build/libs) contains required artifacts.