Posts

Showing posts from June, 2012

How to add a linked sql server using LINQ in C#? -

i'm trying replace hardcoded sql queries linq expressions. here's (simplified) code want replace: list<string> sqlcommands = new list<string> { @"exec sp_attach_single_file_db @dbname='localdb', @physname=n'c:\dbfile.mdf'", @"exec sp_addlinkedserver @server='notlocaldb'" }; sqlconnection conn = new sqlconnection(@"server=.\sqlexpress; integrated security=true"); conn.open(); foreach (string commandstring in sqlcommands) { var command = new sqlcommand(commandstring, conn); command.executenonquery(); } conn.close(); i've replaced sp_attach_single_file_db command linq statement: dbdatacontext localdb = new dbdatacontext(@"server=.\sqlexpress; database=localdb; integrated security=true"); localdb.createdatabase(); but can't find equivalent command sp_addlinkedserver . is there way can create linked server localdb using linq? var connstringbui...

vba - Excel Userform not initialising after first load -

i have workbook has multiple layers of userforms. when workbook opened user presented userform has 2 command buttons, 1 selects worksheet pivottable , slicers , second opens userform containing 8 command buttons, 7 of call further individual userforms , 8 close button. the issue have when select command button opens new userform, close second userform , reselect command button reopen second userform, second userform appears none of command buttons work nor close window (x). the code behind first command button follows: private sub cmd_manageabsence_click() splashscreen.hide load managementfunctions managementfunctions.show end sub the close , terminate code on second userform follows: private sub cmd_close_click() unload managementfunctions end sub private sub userform_terminate() sheets("front").activate splashscreen.show end sub i having same issues second layer of userforms, guess if first layer sorted can apply fix rest. thanks...

regex - Javascript Lookbehind with Global Search Overlapped -

there several (sometimes tricky) solutions lookbehind regexps in javascript. but, easiest way, if need zero width! behind expression global search, may overlap. e.g. using /(?<=[01])\d/g following: var = "--1--01001--1087---"; a.replace(/(?<=[01])\d/g, "#"); // should return "--1--0####--1##7---" if lookbehind supported or example: how can create \b expression works letters ( [a-za-z] ). (lookforward no question. js not support lookbehind). the look-behind through reversal approach seems easiest here. approach best short numeric patterns one. function revstr(str) { return str.split('').reverse().join(''); } var s = "--1--01001--1087---"; var rxp = /\d(?=[01])/g; var result = revstr(revstr(s).replace(rxp, "#")); document.write(result); logics: \d(?=[01]) reversed regex (?<=[01])\d we reverse input string revstr(s) function we reverse replacement result again...

android - Fragment Transaction Commit: State Loss in OnClick? -

i still dont seem state loss error when commiting fragment. have listview onclicklistener: public void onlistitemclick(listview l, view v, int position, long id) { switch (position) { case 0: fragmenttabactivity.addfragments(maintabhostactivity.gettabnames()[0], new openerlocationlistfragment(), true); break; } } and addfragments method: public void addfragments(string tabname, fragment fragment, boolean add) { if (add) { hmaptabs.get(tabname).add(fragment); } fragmentmanager manager = getsupportfragmentmanager(); fragmenttransaction ft = manager.begintransaction(); ft.replace(android.r.id.tabcontent, fragment); ft.commit(); } how can lose state in short time frame? can understand why happens in asynctasks should different here (other allowing state loss)? has suggestions?

multithreading - In Java, multiple threads want to manipulate one object, how to get one manipulate that and the others wait until the work is done? -

my problem little complicated: have concurrent map, threads want visit , update map, if 2 thread want fetch same entry of map, 1 should first map, update it, , other should wait until entry has been updated , fetch entry. original thought that: can use concurrent map, same key targeting map , use latch value. code like: private final concurrentmap<long, list<rowkeymap>> targetmap; private final concurrentmap<long, countdownlatch> helpermap; long keymillis; //key countdownlatch restorelatch = helpermap.get(keymillis); if (restorelatch != null) { try { restorelatch.await(); } catch (interruptedexception e) { thread.currentthread().interrupt(); throw new runtimeexception("interrupted trying " + keymillis); } } list<rowkeymap> restoredata = targetmap.get(keymillis); if (restoredata == null) { //find entry should restored, put latch helpermap , restore restorelatch = ne...

How do I create many matrices inside a loop statement with python? -

i want create example n matrices like: m1 = [[0,0],[0,0]] m2 = [[0,0],[0,0]] . . mn = [[0,0],[0,0]] i think work you res = [[[0 item3 in range(2)] item2 in range(2)] item1 in range(10)] print res output: [ [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0]] ] basically 10(your n value) arrays 2x2 lists of zeros.

c - Prob with binary files using sockets -

this not total code. this working fine normal files text files, not working tar.gz , binary files transfer please me. and how send chunks of memory using sockets. server.c void main() { int sockfd, new_fd; // listen on sock_fd, new connection on new_fd struct sockaddr_in my_addr; // address information struct sockaddr_in their_addr; // connector's address information socklen_t sin_size; struct sigaction sa; int yes=1; char buf[16384]; char remotefile[maxdatasize]; if ((sockfd = socket(af_inet, sock_stream, 0)) == -1) { perror("socket"); exit(1); } if (setsockopt(sockfd, sol_socket, so_reuseaddr, &yes, sizeof(int)) == -1) { perror("setsockopt"); exit(1); } my_addr.sin_family = af_inet; // host byte order my_addr.sin_port = htons(myport); // short, network byte order my_addr.sin_addr.s_addr = inaddr_any; // automatically fill ip memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero); printf("call binding...

ios - Unauthenticated identites not mapping to Developer Authenticated Identity -

when user launches app unauthenticated user , receive unauthenticated cognito identity supplied developerauthenticatedidentityprovider class in ios app. can see unauthenticated cognito identity in cognito console. however, when login , make call nodejs backend logins map of: { devauthidentitylogin:<username> } and using backend code: getcognitoidentity: function(logins, cognitoid, error) { var cognitoidentity = new aws.cognitoidentity(awsoptions); var params = { identitypoolid: identitypool, logins: logins, tokenduration: (60 * 5) }; cognitoidentity.getopenidtokenfordeveloperidentity(params, function(err, data) { if (err) { console.log(err, err.stack); error(err) } else { console.log(data); // successful response cognitoid(data); } }); } it creates new identity id develope...

arduino - Strange magnetometer readout -

i attempting readout data mpu-9150 magnetometer , getting odd numbers. have accessed magnetometer within imu , getting data changes orientation of imu not within range specified product specification guide. i'm think either variable type using store data or method using manipulate twos compliment data make readable, here code anyway... void mpu9150::getmag(double* mag_x, double* mag_y, double* mag_z){ uint8_t asax, asay, asaz; i2cdev::writebyte(mpu9150_address, int_pin_cfg, 0x02);//set i2c bypass enable pin true access magnetometer. i2cdev::writebyte(mpu9150_mag_address, mpu9150_mag_cntrl, 0x0f);//fuse rom access mode. i2cdev::readbytes(mpu9150_mag_address, mpu9150_mag_asax, 3, buffer);//get sensitivity adjustment values. asax = buffer[0]; asay = buffer[1]; asaz = buffer[2]; // serial.print("asax = "); serial.print(asax); serial.print("\n"); // serial.print("asay = "); serial.print(asay); serial.print(...

mysql is not using the correct timezone in a windows server -

i'm having weird issue on timezone used mysql server running on windows server 2012 things have done: set default timezone in my.ini file, in case default-time-zone=america/chicago ensure i'm using actual ini file check timezone variable used mysql system loaded timezone tables mysql data folder, cause read in windows tables aren't there default check server actual time correctly set utc-06:00, same time chicago run select now() statement the last item in list returning me different time, 5 hours ahead, 1 thing when restart server time timezone correctly set chicago time, after few days, got incorrect one, 5 hours ahead. i have no idea why happening, maybe can me this, thanks! after establishing mysql connection please run query. set session time_zone = 'america/chicago'

azure - BadRequest on 'Update autoscale settings' in ARM template deployment -

i'm trying apply scaling settings availability set in templated deployment. i've not been able find complete examples of particular use case in azure-quickstart-templates compare against, , error incorrect syntax uninformative 'badrequest' no other information. here's autoscale settings template (which otherwise deploys fine)... { "apiversion": "2014-04-01", "dependson": [ "microsoft.compute/availabilitysets/workersas" ], "location": "[resourcegroup().location]", "name": "workersscaling", "properties": { "enabled": true, "name": "workersscaling", "profiles": [ { "capacity": { "default": 2, "maximum": 4, "minimum": 2 }, ...

c# - Entity framework 6 lazy loading oddity -

i have poco class wired entity framework. class called personalizationcatalogprice. class has sub object called pricelevel not have virtual keyword on it. because of (based on understanding) object should never lazy load , should return null. however, have found object seems load when used in specific manner. so basic class structure this public class personalizationcatalogprice { public int personalizationcatalogpriceid { get; set; } public int personalizationcatalogid { get; set; } public virtual personalizationcatalog personalizationcatalog { get; set; } public decimal customerretail { get; set; } public decimal consultantcost { get; set; } public decimal personalvolume { get; set; } public decimal qualifyingvolume { get; set; } public int pricelevelid { get; set; } public pricelevel pricelevel { get; set; } } here example. in first line return iqueryable of personalizationcatalogprice ite...

WPF How to put new data in some row in ListView under old data -

i have trouble listview not know do. create gridview inside listview , have ajust data in listview, what have write new data information in existing row new data have in same row, color have different , new data have undern old data. old data not change, 2 column , 4 column data crossed my xaml: <listview x:name="lbpersonlist" margin="30,98.4,362,150" scrollviewer.verticalscrollbarvisibility="visible" alternationcount="2" > <listview.view> <gridview> <gridviewcolumn> <gridviewcolumnheader content="product"> </gridviewcolumnheader> <gridviewcolumn.celltemplate> <datatemplate> <textblock text="{binding name}" fontsize="18px" fontfamily="arial" ...

bolt cms - use tablename different than slug -

i buliding single-language website (german) have code/tables etc. in english. when define contenttype so: plays: name: theaterstücke slug: theaterstuecke tablename: plays singular_name: theaterstück singular_slug: theaterstueck bolt uses table bolt_plays in twig have use ....records = "theaterstueck/latest/6". have template use english routes ("play/latest/6") , url still http://example.com/theaterstuecke do have use translations , routing or there easier way? change both slugs : plays: name: theaterstücke slug: plays tablename: plays singular_name: theaterstück singular_slug: play and should fine

Whitelist domains Selenium / Firefox can connect to -

i using selenium webdriver firefox. wondering if there setting can change such requesting resources domains. (specifically want request content on same domain webpage itself). my current set up, written in python, is: selenium import webdriver firefox_profile = webdriver.firefoxprofile() ## here, change various default setting in firefox, , install couple of monitoring extensions driver = webdriver.firefox(firefox_profile) driver.get(web_address) what want do, if specify web address wwww.domain.com , load content served domain.com , , not e.g. tracking content hosted other domains typically requested. hoping achieved change profile settings in firefox, or via extension. note - there similar question (without answer) - restricting selenium/webdriver/htmlunit domain - 4 years old, , think selenium has evolved lot since then. with vicky, (who's approach of using proxy settings followed - although directly selenium), code below change proxy settings in firefo...

azure - Please wait until the service objective assignment state for the database is marked as 'Completed' error message -

we have 3 databases in azure sql appear locked. run query alter database [dbname] modify(edition='basic',service_objected='basic') or alter database [dbname] modify(edition='standard',service_objected='s2') and end error message; "a service objective assignment on server '[servername]' , database '[dbname]' in progress. please wait until service objective assignment state database marked 'completed'." they have been sitting in state, little clock next edition several days now. appreciated! you can check database state using serviceobjectiveassignmentstate property before performing db changes rest api: https://msdn.microsoft.com/en-us/library/azure/dn505708.aspx powershell: https://msdn.microsoft.com/library/azure/dn546735.aspx

java - Anti virus false positive? -

sometimes program picked anti virus virus there can tell developer line of code causing this? or @ least class or file? often antivirus of emails (like gmail) block possibility add jar file attachment. simply rename different name if problem. for example instead of mylib.jar rename to mylib.jar.rename

java - JPA @ManyToOne update association link in both sides -

class a @manytoone private b b; class b @onetomany (mappedby ="b") private list<a> lista = new arraylist<a>(); private void adda(a a) { lista.add(a); } so owning side, if a.setb(new b()) merge work , association kept. if b.adda(new a()) merge b, link between , b not updated right ? should b.add(new a()) update link between , b ? thank much i don't understand question well, think should add in method adda private void adda(a a) { lista.add(a); a.setb(this); }

vba - Excel CSV files delimiter change -

i'm creating in excel sub-folder in directory , save there multiple csv-files excel workbook my problem need on system list separator ','. csv files getting read system default list separator ';'. cannot change this so need change ',' in csv files ';'. idea achieve using powershell. my first attempt change delimiter of csv after creating in excel passing script file-name. manage change delimiter file struggle pass pathname script (no error no change in file): script code: param([string]$path) $content = [io.file]::readalltext($path) #readparameter import-csv -path $content -delimiter ','|export-csv -path c:\users\desktop\temp.csv -delimiter ';' -notypeinformation #export csv-file ; (get-content c:\users\desktop\temp.csv) | % {$_ -replace '"', ""} | out-file -filepath c:\users\desktop\temp.csv -force -encoding ascii #remove " file remove-item -path $content #remove old csv-file rename-item -...

web applications - Build same same web for different ccTLD -

i building webapp meteor. my webapp have same ui (and pages) in different languages. localized , deployed on different cctlds (.cz, .sk, .hu, .tr, ... .com). here similar case of want. czech parfums eshop . when scroll down bottom, there flags (links) different domains. my webapp can broken down pieces: [db] database can same many languages. [common-code] of code same between different languages [routing & i18n] different parts every languages routing file , i18n file(s) there should way how build/run/debug app different routing file , i18n file(s). i don't want have 1 .com domain , able switch languages. why? consider using 1 code base internationalization files. can use tap-i18n package ( https://github.com/tapevents/tap-i18n ) along iron-router , iron-router-i18n package ( https://github.com/yoolab/iron-router-i18n ). example: meteor create intl meteor add tap:i18n meteor add iron:router meteor add martino:iron-router-i18n this creates basi...

sql server - How to use group by only for some columns in sql Query? -

the following query returns 550 records, grouping columns in controller via linq. however, how can achieve "group by" logic in sql query itself? additionally, post-grouping, need show 150 results user. current sql query: select distinct l.id loadid , l.loadtrackingnumber loaddisplayid , planningtype.text planningtype , loadstatus.id statusid , loadworkrequest.id loadrequestid , loadstatus.text status , routeids.routeidentifier routename , planrequest.id planid , originpartyrole.id originid , originparty.id originpartyid , originparty.legalname origin , destinationpartyrole.id destinationid , destinationparty.id destinationpartyid , destinationparty.legalname destination , coalesce(firstsegmentlocation.window_start, originlocation.window_start) startdate , coalesce(firstsegmentlocation.window_start, originlocation.window_start) begindate , destlocation.window_finish enddate number domain.loads (nolock) l inner join dbo.li...

ios - Swift: Parsing Array of object -

i have contact object can have , array of address objects. class contact { var firstname: string = "" var lastname: string = "" var middlename: string = "" var id: int = -1 var addresses: array<address> = [] how initialize each address object while fetching json dictionary? init(json: dictionary<string, anyobject>) { if let line1 = json["streetline"] as? string { self.streetline1 = line1 } if let city = json["city"] as? string { self.city = city } if let state = json["state"] as? string { self.state = state } if let zip = json["zip"] as? int { self.zip = zip } tried doing this: if let addressmap = json["addresses"] as? array<dictionary<string, anyobject?>> { address as? address in addressmap { addresses.appe...

swift - How can I convert a PFUser into a String? -

how can convert pfuser value type string display on label? something this: username = pfuser.getcurrentuser() a pfuser.currentuser() returns pfobject many different properties. need data out of object , put on string. for instance, if wanted current user's username.. let username = pfuser.currentuser()?.username

php - Make MediaWiki show real names instead of usernames -

i want show users' real names (when have one) instead of usernames. have tried extensions deprecated. running mediawiki 1.26alpha. the reason want show is, running internal wiki corporation ldap login. migrating single ldap/ad , avoid complications employees must login employee id, not username. makes no sense show in wiki, want them login id username instead want real name displayed. category:real name display extensions has bunch of extensions doing along these lines, of not deprecated (although rather old).

css - Make a float div shift div in another-container when collide -

Image
two columns of boxes, , sometimes, left-column boxes can larger column, , have move down rigth-column boxes avoid collision. boxes of right or left column can contained or not, don't know # of larger box. can floated, block or inline, etc. i have this: i want this: is somehow possible css only? jsfiddle (first screenshots) thanks! got it! setting greens inline-block , float: left on blues (and not parents) works expected. no js ;) jsfiddle (i inverted blue , green in attemps)

What is the difference between apache2 reload, restart, graceful? -

i using apache2 project , wondering difference between: service apache2 restart service apache2 reload service apache2 graceful ? thanks answers. there main difference between 4 different ways of stopping/restarting main process threads, , itself. note apache recommends using apachectl -k command, , systemd, command replaced httpd -k apachectl -k stop or httpd -k stop this tells process kill of threads , exit apachectl -k graceful or httpd -k graceful apache advise threads exit when idle, , apache reloads configuration (it doesn't exit itself), means statistics not reset. apachectl -k restart or httpd -k restart this similar stop, in process kills off threads, process reloads configuration file, rather killing itself. apachectl -k graceful-stop or httpd -k graceful-stop this acts -k graceful instead of reloading configuration, stop responding new requests , live long old threads around. combining new instance of httpd can powerful in havi...

c# - Extending a custom resumable download class -

i have event handler named downloadprogresschanged in download class. takes 4 arguments through downloadprogresschangedeventargs class, bytesreceived, totalbytestoreceive, progresspercentage & currentspeed. i'm able download , resume files. stop them too. adding data needeed the downloadprogresseventargs making me confused. main problem don't know info needed bytesreceived argument is. can point me in right direction? public class download { public event eventhandler<downloadprogresschangedeventargs> downloadprogresschanged; public event eventhandler downloadcompleted; public bool stop = true; // default stop true // add option current downloaded size // add option current download speed public void downloadfile(string downloadlink, string path) { stop = false; // set bool false, everytime method called long existinglength = 0; filestream savefilestream; if (file.exists(path)) { ...

java - how Immutable class is created having mutable object as refernce -

i asking basis question 'how make immutable object in java'. so have 1 address class third party not inherit cloneable interface , mutable class. looks this public class address { private string city; private string address; public string getcity() { return city; } public void setcity(string city) { this.city = city; } public string getaddress() { return address; } public void setaddress(string address) { this.address = address; } } now have immutable class called person implements cloneable interface , override clone method.class looks public class person implements cloneable { private string name; private address address; public person() { } public person(string name, address address) { this.name = name; this.address = address; //this.address = (address) address.clone(); } public string getname() { return name; } @o...

warnings - Java 8: What is the equivalent of "UseSplitVerifier"? -

i'm using maven 3.2.3 on mac 10.9.5 , have compiler plugin ... <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerargument>-proc:none</compilerargument> <fork>true</fork> <!-- <compilerid>eclipse</compilerid>--> </con...

Double loop Ansible -

i have object that objs: - { key1: value1, key2: [value2, value3] } - { key1: value4, key2: [value5, value6] } and i'd create following files value1/value2 value1/value3 value4/value5 value4/value6 but have no idea how double loop using with_items yes. can. take @ with_subelements in here http://docs.ansible.com/ansible/playbooks_loops.html#nested-loops you need create folders: iterate though objs , create files: here example: --- - hosts: localhost gather_facts: no vars: objs: - { key1: value1, key2: [ value2, value3] } - { key1: value4, key2: [ value5, value6] } tasks: - name: create files file: path="{{ item.key1 }}" state=directory with_items: objs - name: create files file: path="{{ item.0.key1 }}/{{ item.1 }}" state=touch with_subelements: - objs - key2 an output pretty self explanatory, second loop iterates through values way need...

html - CSS height: 100% not working on inline-block element although parent div has height -

i have div has 2 child divs inside it, so: <div id="cartgrid" style="display:inline-block"> <div class="cart-left"> .... </div> <div class="cart-right"> .... </div> </div> the .cart-left holds table of items, while .cart-right has few buttons, .cart-left taller .cart-right ; height of parent div determined height of .cart-left . want .cart-right have same height .cart-left , gave height:100% , though parents ( #cartgrid ) has height value, height:100% nothing. fiddle: https://jsfiddle.net/zjuzh07n/ a bit dirty, that's how fix it. #cartgrid { position: relative; display: inline-block; } .cart-right { position: absolute; display: inline-block; right: 0; height: 100%; } hope might help.

android.support.design.widget.TextInputLayout gives InflateException -

i trying use textinputlayout in design library , added support libraries following: dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.google.android.gms:play-services:4.0.30' compile "com.android.support:support-v4:+" compile 'com.squareup.picasso:picasso:2.3.2' compile 'com.nineoldandroids:library:2.4.0' compile 'com.daimajia.slider:library:1.1.5@aar' compile 'com.navercorp.pulltorefresh:library:3.2.0@aar' compile filetree(dir: 'libs', include: 'parse-*.jar') compile filetree(dir: 'libs', include: 'parsecrashreporting-*.jar') compile 'uk.co.chrisjenx:calligraphy:2.1.0' compile 'com.android.support:design:22.2.1' } however, gives me following error. might cause of it? e/androidruntime﹕ fatal exception: main android.view.infl...