Posts

Showing posts from July, 2015

javascript - Hide an input until a checkbox has been checked -

in following form how can hide <input> tag after checkbox , show when checkbox checked? <ul style="list-style-type:none"> <li> <input type="text" name="accountname" style="width:95%" class="field-style field-full align-none" placeholder="company name" /> </li> <li> <label>please fill in contact information below</label> <input type="text" name="firstname" class="field-style field-split align-left" placeholder="first name" /> <input type="text" name="lastname" class="field-style field-split align-right" placeholder="last name" /> </li> <li> <input type="text" name="address" class="field-style field-split align-left" placeholder="street # , name" /> <sele

.net - C# Serialize expression -

i serialize expression. (create iquery clientside -> send server -> execute -> return result client) but expressions not serializeable. gnupacket serialize.linq ( https://github.com/esskar/serialize.linq ) still have problem. following exception thrown: error converting type: der typ 'prog.db.query`1[[prog.database.user, prog.database, version=1.0.0.0, culture=neutral, publickeytoken=null]]' mit dem datenvertragsnamen 'arrayofuser: http://schemas.datacontract.org/2004/07/prog.database ' wird nicht erwartet. verwenden sie ggf. einen datacontractresolver, oder fügen sie alle unbekannten typen statisch der liste der bekannten typen hinzu, beispielsweise mithilfe des knowntypeattribute-attributs oder indem sie sie zur liste der bekannten typen hinzufügen, die datacontractserializer übergeben wird. i added known types jsonserializer js = new jsonserializer(); js.addknowntypes(assembly.getassembly(typeof(prog.database.

Retrieve data from facebook graph API 2.4 -

can me retrieve data using new graph api v2.4 of facebook, using url- https://graph.facebook.com/ {user-id}/feed?limit=1&locale=en_gb&access_token={access-token} previously provides data, (provide data view in json format) "id": "12345_67890", "from": { "name": "xyz", "id": "123456" }, "message": "hwregdsfdsf", "link": "http://example.com/wordpress/", "name": "example.com", "caption": "example.com", "icon": "https://www.facebook.com/images/icons/post.gif", "actions": [ { "name": "comment", "link": "https://www.facebook.com/12345/posts/67890" }, { "name": "like", "link": "https://www.facebook.com/12345/posts/67890"

excel - VBA timer gives 0s for everything -

i have timer calculates differences in execution times between data types performing same calculation. here macro: public declare function gettickcount lib "kernel32.dll" () long sub function1_var_randnumcounter() dim var_randnum_x variant, var_randnum_y variant, count variant count = 1 count = 1000000000 var_randnum_x = rnd(now) ' rnd vals based on now, built-in vba property var_randnum_y = rnd(now) next count select case isnull("a2") case true cells.clear set target_sheet = activesheet target_sheet.range("a2").value = -t case false set target_sheet = activesheet target_sheet.range("a2").value = -t end select 'msgbox gettickcount - t, , "milliseconds" call function1_dec_randnumcounter end sub sub function1_dec_randnumcounter() dim count, var_randnum_x, dec_randnum_x, var_randnum_y, dec_randnum_y dec_randnum_x = cdec(var_randnum_x) dec_randnum_y = cdec(var_ra

excel - VBA updating data series forumla changing formatting -

i'm having unexpected issue code. it's suppose update 2 data series of chart object dynamically. i've added series collection(a total of 3 series now). data series update problem formatting 3 series swap around between each other every time update occurs. here code below updating occurs: dim wrksheet string wrksheet = application.worksheets(x).name if background > 0 'update background data series application.worksheets(x).chartobjects("main chart").chart.seriescollection(2).formula = _ "=series(""background"",('" & wrksheet & "'!$j$32:$j$" & (32 + background - 1) & ",'" & wrksheet & "'!$j$" & backgroundstart2 & ":$j$" & (backgroundstart2 + background - 1) & ")," _ & "('" & wrksheet & "'!$k$32:$k$" & (32 + background - 1) & ",'" & wrkshe

javascript - Convert dd-mm-yyyy string to date -

i trying convert string in format dd-mm-yyyy date object in javascript using following: var = $("#datepicker").val(); var = $("#datepickertwo").val(); var f = new date(from); var t = new date(to); ("#datepicker").val() contains date in format dd-mm-yyyy. when following, "invalid date": alert(f); is because of '-' symbol? how can overcome this? parse string parts need: var = $("#datepicker").val().split("-"); var f = new date(from[2], from[1] - 1, from[0]); why not use regex? because know you'll working on string made of 3 parts, separated hyphens. however, if looking same string within string, regex way go. reuse because you're doing more once in sample code, , maybe elsewhere in code base, wrap in function: function todate(datestr) { var parts = datestr.split("-"); return new date(parts[2], parts[1] - 1, parts[0]); } using as: var = $("#datepi

android - Get specific json object by ID using GSON -

i trying develop skills in json parsing. have found have implement kind of json parsing library example gson. have json example here . , code using values json: private class postfetcher extends asynctask<void, void, string> { private static final string tag = "postfetcher"; public static final string server_url = "http://kylewbanks.com/rest/posts"; @override protected string doinbackground(void... params) { try { //create http client httpclient client = new defaulthttpclient(); httppost post = new httppost(server_url); //perform request , check status code httpresponse response = client.execute(post); statusline statusline = response.getstatusline(); if(statusline.getstatuscode() == 200) { httpentity entity = response.getentity(); inputstream content = entity.getcontent(); try {

java - "Failed to transform class with name [CLASS NAME]. Reason: javax.servlet.ServletContext" when running tests in an ANT script -

i initialization error in logs when try run particular suite of tests after running ant test tasks. full stack trace follows: failed transform class name [class name]. reason: javax.servlet.servletcontext java.lang.illegalstateexception: failed transform class name [class name]. reason: javax.servlet.servletcontext @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:266) @ org.powermock.core.classloader.mockclassloader.loadmodifiedclass(mockclassloader.java:180) @ org.powermock.core.classloader.defersupportingclassloader.loadclass(defersupportingclassloader.java:68) @ java.lang.classloader.loadclass(classloader.java:357) @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:792) @ java.lang.classloader.defineclass(classloader.java:635) @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:269) @ org.powermock.core.classloader.mockclassloader.loadmodifiedclass(mockclas

hook - Dynamically Display liferay-search-container columns based on Arraylist? -

i trying display columns of liferay grid dynamically. same reason reference suggestion following link, dynamic columns in liferay-ui:search-container? , giving option user selected required columns of table in configuration page. selected columns of config page saving in array list. issue: need display columns based on array list values. instead hard coding column properties need iterate list , display selected column in table/grid. let's assume working on liferay default user_ model. selected columns of config page saving in 1 list follows, arraylist<string> al = new arraylist<string>(); iterator<string> itr = al.iterator(); while(itr.hasnext()) { string columnname = itr.next(); columnname = columnname.trim().tolowercase(); string columnval = portletpreferences.getvalue(columnname, stringpool.blank); al.add(columnname); } now let's assume user has selected following columns in config pag

c# - two dimensional label not working -

i have code display 81 labels in table. when try write code not displaying labels. can tell me problem ?? label[,] val = new label[9,9]; point p = new point(); p.x = 300; p.y = 300; (int = 0; < 9; i++) { (int j = 0; j < 9; j++) { val[i, j] = new label(); val[i, j].location = p; p.x = p.x + 20; val[i, j].text = i.tostring(); this.controls.add(val[i, j]); } p.y = p.y + 50; } as hungpv pointed, you using same point object try this: label[,] val = new label[9, 9]; int x = 0; int y = 0; (int = 0; < 9; i++) { (int j = 0; j < 9; j++) { val[i, j] = new label(); val[i, j].location = new point(x,y); x += 20; val[i, j].text = "row: " + +"column: " + j; controls.add(val[i, j]); } y += 50; }

c++ - How to detect Cross GCC compiler using Macros -

i found interesting article: c/c++ tip: how detect compiler name , version using compiler predefined macros is possible detect using macro if current compiler cross gcc (the 1 used default eclipse cdt )? it easy detect, if compiling e.g. arm, not possible detect macro, if compiling arm on arm or cros-compiling on x86. you need support in build system , pass variable compiler gcc -dis_crosscompiling=1 using gcc dump preprocessor defines check output of cross compiler , system compiler. there lot of defines nothing cross compilation. according http://www.gnu.org/software/automake/manual/html_node/cross_002dcompilation.html autotools performing check checking whether cross compiling... yes and hope result can made visible gcc. you can run ugly command check sort of cross compilation gcc -march=native -e - < /dev/null this command fail, if cross compiler different architecture, not fail, if different operating system.

jquery - How to prevent a background gradient from starting all over? -

Image
i have simple web site articles/cards on it. background use gradient. body, html { height:100%; padding:10px 0 0 0; margin:0; background: #99b8cc; background: linear-gradient(to top, #c8dae6 33%, #99b8cc 100%); font-family:'open sans', sans-serif; height: 1000px; max-width: 1000px; /*overflow-y: scroll;*/ } it's fine! upon clicking on card, expands, increases overall page height. when reaching "first 100% height", background gradient starts on again. how can prevent starting on again? gradient should use "new" 100% page height. jquery used on page, if helps. your height first defined 100% , after, redefine height: 1000px; , , override first one. just remove height: 1000px; solve that. or maybe, need rule: min-height: 1000px; (instead of height: 1000px; ) depending on trying do.

c++ - Can OOP be used in Embedded C? -

i'm new software development , loving it. currently, work involves c++ programming in oop implementation (basically, guys started framework software used oop approach in everything). jumped in , inherited what's there. hobby-wise, develop framework embedded application. programming embedded c on microcontroller. wise framework in oop approach also? thinking more organized. thanks in advance answers! i depends on microcontroller specifications (and how many resources have). in experience (as olaf says it's subjective opinion): oop approach clearer, avoids mistakes common variables , allows other person use framework without painful learning process. however... require more resources need encapsulate , leads more functions. so... depends...

Rails authentication with LDAP -

i learning rails(no experience in web development , mvc), , improve skills, wanted implement application authentication done in ldap. have been reading rails 4 in action ryan bigg , ruby on rails tutorial michael hartl. in tutorials, applications developed needs authentication system. build authentication system scratch. since username/passwords saved in database generate user model. question is, if save user data in ldap(and authentication via ldap), need generate user model? user model used saving cookies(to remember user sessions). mean should generate user model save session data? pointer appreciated. you not need create model inheriting activerecord::base class, having class hold user information suitable - if duration of run time. or wanto authentication , forget user? if interested in using ldap de facto standard rails gem authentication - devise , take @ wiki page https://github.com/plataformatec/devise/wiki/how-to:-authenticate-via-ldap . all have do, use cu

java - Android: speeding up shared element transition between activities -

i have shared element transition between 2 activities works in following way: intent someintent = new intent(this, someclass.class); if (build.version.sdk_int >= 21) { activityoptions options = activityoptions.makescenetransitionanimation(this , new pair<>(viewclicked.findviewbyid(r.id.someimage), "someimage") , new pair<>(viewclicked.findviewbyid(r.id.someicon), "someicon") ); startactivity(someintent, options.tobundle()); } else { startactivity(someintent); } this works fine, transition agonisingly slow. when image first clicked on seems stall second or 2 before transition takes place. due "weight" of activity being loaded or delay configurable? did try change duration of entertransition , returntransition : private transition entertransition() { changebounds bounds = new changebounds();

ios - How to use NSRegularExpression in Swift 2.0 in xcode 7 -

//the error here let regex = nsregularexpression(pattern: "(<img.*?src=\")(.*?)(\".*?>)", options: nil, error: nil) //the error is:*** cannot find initializer type nsregularexpression accept argument of type (pattern: string,ption:nil,error:nil) there 2 changes regards syntax in swift 2.0: (1) wrap call in try ... catch block instead of supplying error parameter; , (2) options should set , not numerical or of individual options. in case code should this: do { let regex = try nsregularexpression(pattern: "(<img.*?src=\")(.*?)(\".*?>)", options: []) } catch let error nserror { print(error.localizeddescription) } if know pattern succeeds, can shorten this: let regex = try! nsregularexpression(pattern: "(<img.*?src=\")(.*?)(\".*?>)", options: []) now if want set options pattern, can this: let regex = try! nsregularexpression(pattern: "(<img.*?src=\")(.*?

javascript - Typescript Decorator, which overrwrites set of property -

im trying overwrite "set" of property decorator decortaor: function maxlength(maxlength: number) { return function (target: object, key: string, descriptor: typedpropertydescriptor<string>) { var oldset = descriptor.set; descriptor.set = (value) => { oldset.call(this, value); } } } decorated property: private _entry: string = null; @maxlength(30) public entry(): string { return this._entry } public set entry(value: string) { this._entry = value } when " oldset.call(this, value)" gets called, "_entry"-field stays empty. does know correct way overwrite "set"-mehtod? in case, don't use arrow function . currently this in oldset.call(this, value); equal global object—not instance of class. instead of assigning instance's property assigns window._entry . change code instead use regular function, use function's this : descriptor.set = function(value) {

c++ - Executing a program on PocketPC Today Items doesn't work -

i have following problem. using dll add new menu item today item list on pocketpc 2002. have tested written dll on windows mobile 6.5.3 works on there. on pocketpc path contains space , guess don't escape string right. consider following snippet problem occurs: char commandline[100]; strcpy(commandline, "\\sdmmc disk\\test\\test.exe"); startupinfo si = { sizeof(si) }; int len; int slength = (int)strlen(commandline) + 1; len = multibytetowidechar(cp_acp, 0, commandline, slength, 0, 0); wchar_t* buf = new wchar_t[len]; multibytetowidechar(cp_acp, 0, commandline, slength, buf, len); process_information pinfo; ::createprocess(buf, buf, null, null, false, 0, null, null, &si, &pinfo); now trying escape path executable this: strcpy(commandline, "\"\\sdmmc disk\\test\\test.exe""); but unfortunately not work. did escape string in wrong way? i'd appreci

amazon web services - How to choose production server/cloud for Apache Solr 5.1.0? -

i have configured apache solr 5.1.0 in pc searching server application. now want upload on live server production environment. many people suggested me use amazon web services(aws) don't know ec2 or vpc how choose among these & plan normal solr application indian region ?? is there other service solr hosting?? realistically dude, no 1 going tell here going best setup. considering post has 0 technical information or requirements. do favor , develop requirements, compare various plans... in due-diligence.

PHP dynamically get the data from a sub array -

i have question. have script renames array keys. now want in sub level array if needed. current situation the current code have works : ///######## if original key has been set if(isset($this->prepareddata[$key]) === true){ ///######## add data prepared data variable $this->prepareddata[$value] = $this->prepareddata[$key]; ///######## unset original key unset($this->prepareddata[$key]); } but want code able set following dynamically: ///######## if original key has been set if(isset($this->prepareddata[$subkey1][$key]) === true){ ///######## add data prepared data variable $this->prepareddata[$subkey1][$value] =$this->prepareddata[$subkey1][$key]; ///######## unset original key unset($this->prepareddata[$subkey1][$key]); } question but want dynamically: so be: $this->prepareddata[$subkey1][$key] but also: $this->prepareddata[$subkey1][$subkey

Android - how to change Recyclerview height dynamically? -

i'm stuck issue changing recycler height based on total items. have tried use layout param this: viewgroup.layoutparams params = myrecyclerview.getlayoutparams(); params.height = itemheight * numberofitem; myrecyclerview.requestlayout(); or viewgroup.layoutparams params = new recyclerview.layoutparams(..wrap_content, ...wrap_content);; params.height = itemheight * numberofitem; myrecyclerview..setlayoutparams(params); but didn't work. how can ? please me ! you should use layoutparams of parent's view in setlayoutparams(params). for example: <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" > <android.support.v7.widget.recyclerview android:id="@+id/images" android:layout_width="wrap_content" android:layout_height="360dp" > </android.support.v7.widget

javascript - Format value of form field -

i have edit form populated corresponding model. has text field has date value associated it. using javascript plugin allows user select date popup, shows nicely in field july 15, 2015 plugin submits hidden field format database expecting. when go edit page field pre-populated ugly date format value , plugin doesn't update format of date when it's initialized, when user picks date. there way in cakephp can pre-format value before it's displayed page? if ran through javascript plugin handle format great. my form field echo $this->form->input('date', array( 'type' => 'text', 'class' => 'pickadate', 'placeholder' => 'pick date', 'required' => true )); the plugin i'm using http://amsul.ca/pickadate.js/date/ $('.pickadate').pickadate format: 'mmmm dd, yyyy' formatsubmit: 'yyyy-mm-dd' hiddenname: true container: 'main'

postgresql - Why does Liquibase want to dropPrimaryKey and addPrimaryKey? -

i have postgres databases generated eclipse link. between these databases not change, when run liquibase generating diffchangelog, generates changesets dropprimarykey , addprimarykey. don't understand why generates these records primary keys of tables. names, order of columns same both tables. example of changeset <changeset author="michal2 (generated)" id="1436872322297-8"> <dropprimarykey tablename="country_translation"/> <addprimarykey columnnames="country_id, translations_id" constraintname="country_translation_pkey" tablename="country_translation"/> </changeset> sql of original table create table country_translation ( country_id bigint not null, translations_id bigint not null, constraint country_translation_pkey primary key (country_id, translations_id), constraint fk_country_translation_country_id foreign key (country_id) references country (id) m

javascript - Position text above fixed text with CSS -

is possible can keep heading above some other area text @ times - when user begins scrolling page? how do css/jquery? demo: http://jsfiddle.net/h49p65qa/ css: * { margin: 0; padding: 0; } .site-wrap { padding:40px 0 } .some-other-area { } h1 { position:fixed; z-index:1; top:0; margin:0; } h2 { padding: 0px; margin: 0px 0 20px 0; } .floatingheader { position: fixed; top: 0; visibility: hidden; } thank you is looking for? js: var el = $(this), offset = el.offset(), scrolltop = $(window).scrolltop() + 50, floatingheader = $(".floatingheader", this) css: .floatingheader { position: fixed; top: 50px; visibility: hidden; } demo: http://jsfiddle.net/h49p65qa/3/

object - Android : Display details of Item in list view when clicked -

i working on android project, displaying list of items user. now, trying when user clicks on item, want id of item, can call upon object details via network , display them in activity. problem is, object displayed contain names. cannot find way, set id of item, hidden, , can retrieve when user clicks , subsequent task. there way set id somewhere cannot seen user , can used. here code : public class restaurantlist extends activity { string restaurantlist = "http://192.168.178.60:8080/restaurant/listing"; private responseentity<restrestaurant[]> responseentity; @override public void oncreate(bundle savedinstancestate) { listview listview = (listview) findviewbyid(r.id.restrestaurantlist); super.oncreate(savedinstancestate); setcontentview(r.layout.restos); resttemplate resttemplate = staticresttemplate.getrest(); thread thread = new thread(new runnable() { @override public void ru

c - What do the instructions mov %edi and mov %rsi do? -

i've written basic c program defines integer variable x, sets 0 , returns value of variable: #include <stdio.h> int main(int argc, char **argv) { int x; x = 0; return x; } when dump object code using objdump (compiled on linux x86-64 gcc): 0x0000000000400474 <main+0>: push %rbp 0x0000000000400475 <main+1>: mov %rsp,%rbp 0x0000000000400478 <main+4>: mov %edi,-0x14(%rbp) 0x000000000040047b <main+7>: mov %rsi,-0x20(%rbp) 0x000000000040047f <main+11>: movl $0x0,-0x4(%rbp) 0x0000000000400486 <main+18>: mov -0x4(%rbp),%eax 0x0000000000400489 <main+21>: leaveq 0x000000000040048a <main+22>: retq i can see function prologue, before set x 0 @ address 0x000000000040047f there 2 instructions move %edi , %rsi onto stack. these for? in addition, unlike set x 0, mov instruction shown in gas syntax not have suffix. if suffix not specified, , there no memory operands instructi

oracle - Exclude Extra Error Information from RAISE_APPLICATION_ERROR -

i have raised error message in pl/sql trigger , works fine except returns more error specify application. in addition custom error information line error happened on , trigger. for example ora-20111: there custom error here ora-06512: @ "{schema_name}.{trigger_name}", line 2 ora-04088: error during execution of trigger {schema_name}.{trigger_name}<br> .operation canceled. what want is: ora-20111: there custom error here how remove information error message before returned application? testing code below... create or replace trigger custom_error before insert or update on {schema_name}.{table_name} each row begin raise_application_error(-20111, 'there custom error here'); end; you use raise_application_error . for example, sql> declare 2 custom_err exception; 3 pragma exception_init( custom_err, -20099 ); 4 begin 5 raise_application_error( -20099, 'this custom error' ); 6 exception 7 when cu

Can I use double click to select and copy in tmux like in iterm2? -

i learning use tmux, found when in tmux window, double-click select , copy function did not work more. can use double-click select , copy in iterm2? i have googled time, did not find short , clear answer this. have added setw -g mode-mouse on in tmux configure file already. i found way achieve that: hold option key when double clicking.

javascript - stop function on mouseup -

i've got mousedown function. $('#manrun').mousedown(function(e3) { var manid = get_id(this); e3.preventdefault(); $(document).on('mousemove.moveman, mousemove.slideman', function(e2) { running(e2, runbtn, manid); }); }); and mouseup function stop running() $('#manrun').on('mouseup', function(e) { e.preventdefault(); $(document).off('mousemove.moveman, mousemove.slideman'); }); but running() function not stop. how can force running() stop when mouse released? i assume mouseup not done on #manrun object. try attach handler document instead. $(document).on('mouseup', function(e) { e.preventdefault(); $(document).off('mousemove.moveman, mousemove.slideman'); });

Creating Consistent Matrix from Segmented Data -

i have segmented b-allele frequency data generated individual samples. each sample form vector of ~600, specifying chromosome location , attached estimated of b-allele frequency in region. aim of detect aberrant regions of genome. my question how best convert individual samples consistent matrix can compare regions between samples. number of segments per sample varies between 550-650. can recommend way can converted matrix regions can approximately comparable.

javascript - Node.js - How do you control Async callback sequence? -

in following example walking on directory tree obtain listing of directories , files. importantly need order of directories , files same visually @ them in file explorer. brevity writing out folders , files console.log in sequence expect them... var fs = require('fs'); var path = require('path'); var walk = function(dir) { console.log(dir); var files = []; var items = fs.readdirsync(dir).sort(function (a, b) { return a.tolowercase().localecompare(b.tolowercase()); }); items.foreach(function(item){ if (item.charat(0) !== '.') { var itempath = path.join(dir,item); if (fs.lstatsync(itempath).isdirectory()) { walk(itempath); } else { files.push(itempath); } } }); files.foreach(function(file){ console.log(file); }); }; walk('c:\\foo\\bar'); this sync version took of 20 minutes develop , enforces exact seque

exe - rtw.codemetrics.C_CodeMetrics' contains a parse error or cannot be found on MATLAB's search path, possibly shadowed by another file with the same name -

i deploying project using deploytool in matlab. added few function files main.m file , run build. stoped on build failed , return error: rtw.codemetrics.c_codemetrics' contains parse error or cannot found on matlab's search path, possibly shadowed file same name. please ....thanks in advance.

authentication - Invalid client credential while getting access token from paypal ios sdk -

i creating app in have use paypal payment, after successful payment have generate payment detail, need access token. i method how access token, tried in hurl. , access token using client id , client secret. till there no problem. but when put credentials (client_id , client_secret) in code returns invalid client credential. nsurl *url = [nsurl urlwithstring:@"https://api.sandbox.paypal.com/v1/oauth2/token"]; // nsurlrequest *request = [nsurlrequest requestwithurl:url // cachepolicy:nsurlrequestuseprotocolcachepolicy // timeoutinterval:30.0]; nsmutableurlrequest* request = [[nsmutableurlrequest alloc] initwithurl:url]; nsstring *client_id = @"xxxxxxxxxxxxxx"; nsstring *client_secret = @"xxxxxxxxxxxxxx"; [request sethttpmethod:@"post"]; nsstring *authstr = [nsstring stringwithformat:@"%@:%@", client_id, client_secret]; nsdata *authdata = [authstr datausingencoding:nsasciistringencoding]; nsstring *authvalue = [nsstring stri

java - Weighted random numbers in 2D Array - Processing -

i fill 3x3 2d array values 1,2,3. i need each number appear given times. for example: 1 appear 2 times 2 appear 4 times 3 appear 3 times what need store numbers array in random position. for example: 1,2,2 3,2,2 1,3,3 i did in simple way using 2 different numbers controlled counter. loop through 2d array , applying random values of number 1 , number 2. i'm checking if value 1 , add in counter , same number 2. if 1 of counter exceeds number have set maximum appear times continues , applies other value. is there better approach fill 3 numbers in random array position? see code below: int [][] array = new int [3][3]; int counter1 =0; int counter2 =0; (int i=0; i<3; i++) { (int j=0; j<3; j++) { array[i][j] = (int)random(1, 3); //1,2 if (arrray[i][j]==1) { counter1++; } else if (array[i][j] ==2) { counter2++; } //if more 5 times in array put other value if (counter1>5)

wwdc - Images in IOS to support 1x, 2x, 3x -

in wwdc 2015, shall use 1x,2x,3x images in assets because iphone 6p download 3x image , ignore other. have watched app thinning. i know whether ios 9 or below also? note: ios apps, sliced apps supported on latest itunes , on devices running ios 9.0 , later; otherwise, app store delivers universal apps customers. from app distribution guide - app thinning

python - Django cors error even after installing cors-headers -

my python view using requests, so: r = requests.post(url, params=data, headers=header) print r.url return httpresponse(r) the object posted redirect url. when url called, activity stops in browser , error thrown: cross-origin request blocked: same origin policy disallows reading remote resource @ https://<website>.com. can fixed moving resource same domain or enabling cors. i have installed django-cors-headers following line added in settings.py: cors_origin_allow_all = true why still getting error? make sure have added correct cors middleware , more importantly sequence , allowed methods too. also, make sure it's listed in installed_apps setting.

c# - Error with quotes in search query -

Image
i displaying report using sql query. in report user can search customer. created search function. searchfield customer (selected dropdownlist) , search terms user enters textbox search: stringbuilder sql = new stringbuilder(searchsql); if (searchfieldkey != null && searchfieldkey.length > 0) { if (searchterms != null) { sql.append(" having "); (int = 0; < searchfieldkey.length; i++) { if (searchfields.containskey(searchfieldkey[i])) { sql.append(searchfields[searchfieldkey[i]] + " ?parameter" + i.tostring()); param.add(new mysqlparameter("parameter" + i.tostring(), "%" + searchterms[i] + "%")); if (i != searchfieldkey.length - 1) sql.append(" or "); } else throw new exception("error: attempted search on invalid field. check searchfields argument."); } } } sql.append(" '); "); sql.appen

javascript - About reportlab -

i have problem with reportlab. want create pdfs data coming javascript code chinese or other non-roman letters in it. tried using different techniques in unicode still appears black boxes in pdf. have in js these , want make text "warranty ....." chinese or something. content.find('#wtc') .html('<br/><span style="font-size:20px;color:rgb(9,79,163);"> warranty general terms , conditions</span>'); when in roman characters, fine. however, if insert [&]#21512; doesn't show should >> 合 can me here? in advance! ps, please bear me. i'm new here in reportlab. maybe need add reportlab fonts support encoding want? example: dfmetrics.registerfont(ttfont('times-italic', 'timesi.ttf', 'utf-8')) pdfmetrics.registerfont(ttfont('times-bolditalic', 'timesbi.ttf', 'utf-8')) reportlab.lib.fonts import addmapping addmapping('times', 0, 0

python - How do I add one more loop to this? -

part of code is: list1 = zeros((x,y)) j in range(1,y): in range(1, x-1): list1[i,j] = list1[i,j-1] + equation this works fine. however, when want next stage, need modify "equation" part in second loop. equation (a*b+c)*d , wish make 1 of parameters(a,b,c,d) varying every increase in j . that is, when j 1, a = something . when j increases 2, changes according. function of j . example: a = a*cos(w*j) . my problem is, how loop relation code a updated every time? just add expression in outer loop, calculating a based on changing value of j : for j in range(1, y): = * cos(w * j) in range(1, x-1): list1[i, j] = list1[i, j - 1] + (a * b + c) * d

android - Recyclerview grid layout manager that fills one column first -

i recyclerview layout manager works gridlayoutmanager 2 columns fills first column first before adds items 2nd column. or rather adds remaining items second column. suggestions? there's no direct layout manager but , guess it's better, easier, more rational re-order list or whatever data structure filling adapter trying mess layout manager. an example of how during bindview : public void onbindviewholder (vh holder, int position) { position = translateposition(position); // carry on normal bind code } then create method translateposition simple math re-order stuff way want/need.

ruby on rails - The action 'new' could not be found for DeviseTokenAuth::SessionsController -

set authentication angularjs , ruby on rails, use gem devise_token_auth. when run test rspec have same error failure/error: unable find matching line backtrace abstractcontroller::actionnotfound: action 'new' not found devisetokenauth::sessionscontroller i saw different sites try new controller example: class devise::sessionscontroller < applicationcontroller didn't me. going purely error supplied, create sessions controller: class sessionscontroller < devise::sessionscontroller def new end end you can either manually or run: rails generate devise:controllers [scope] from within app directory in terminal. (replace scope model devise interacts with, e.g user). also, give read. https://github.com/plataformatec/devise

visual studio - How to copy some file to output directory through 2+ projects -

i have somedll1 have somefile.txt properties buildaction: content copy: copy if never i have somedll2 have reference somedll1. have consoleapp have reference somedll2. after build of consoleapp need rebuild somedll1 copying somefile.txt consoleapp output directory. not comfortably. can add reference somedll1 in consoleapp solve problem. dont it. may there other solution? check solution's properties > project dependencies. your consoleapp should depend on somedll1 . means somedll1 re-built each consoleapp build (automaticly) , references on place. actually, project dependencies after create projects , adding references described. possibly, you've unchecked manually. check since not references solution build order tooling. for older versions of visual studio (2010 , lower) there problems in described case. see: how include neccessary files output of independent client project?

Google query for a mass of related websites -

is there way load bunch of urls hundred of them , query in google find other related those. to more specific command as_rq=www.example.com in google query searches sites related url, if want search vast amount of urls there option or i'll have traverse urls 1 one. unfortunately not possible multiple url queries. i've tried myself before no luck after searching multiple online forumns

javascript - Undefined index with php and ajax -

why var in php undefined? code html <table> <tbody id="table"> <tr> <th colspan="2">signup</th> </tr> <tr> <td>firstname:</td><td>lastname:</td> </tr> <tr> <td><i class="fa fa-user"></i><input type='text' maxlength="25"autocomplete="off" size="20" id="fn"></td><td><i class="fa fa-user"></i><input type='text' maxlength="25"autocomplete="off"size="20" id="ln"></td> </tr> <tr> <td colspan="2"><div>djname(username):&nbsp; <i class="fa fa-headphones"></i><input type='text' maxlength="25"autocomplete="off"size="20&qu

wpf - Render control in multiple places -

Image
is there way show same control partially in more 1 place in wpf? such feature implemented in microsoft office excel, can split current workspace in 2 duplicates. i know, controls cannot have 2 parents, may solution rendering control second parent space , emulating of input events exists. i make usercontrol s share 1 view model. guess such controls in office products not rendering identical instance @ multiple places.

c# - Angular 2 routing resource not found -

i using vs 2015 rc, working on webapi project , when try use routing in angular 2 following errors: failed load resource: server responded status of 404 (not found) localhost:14580/angular2/router potentially unhandled rejection [3] error loading "angular2/router" @ localhost:14580/angular2/router error loading "angular2/router" "components/main/main" @ localhost:14580/components/main/main.js not found: localhost:14580/angular2/router (warning: non-error used) the view basic import of main.ts component. component code follows: /// <reference path="../../scripts/typings/angular2/angular2.d.ts" /> /// <reference path="../../scripts/typings/_custom/ng2.d.ts" /> import {router, routeconfig, routerlink, routeroutlet} 'angular2/router'; import {component, view, bootstrap} 'angular2/angular2'; import {login} '../login/login'; import {status, json} 'scripts/utils/fetch' // a

python - slicing column in numpy array and creating new matrix -

i have concatenate columns of numpy matrix create new matrix. have 2 codes. 1 working fine. other giving me trouble. 1 working fine is x = np.array(range(24)) x = x.reshape((3,4,2)) y = np.array(range(100,124)) y = y.reshape((3,4,2)) z = np.concatenate((x,y)) now result 6,4,2 if axis =0 si 3,8,2 if axis=1 , 3,4,4 if axis=2. @ code: a=np.array(([1,2,3],[4,5,6],[7,8,9]) b=a[:,1] # took 1 column c=a[:,0] # again took 1 column d=np.concatenate((b,c)) if provide axis=0 result 1x6. if provide axis=1 again 1,6. want in 1 case 1,6 in 3,2. ie [2,1],[5,4],[8,7] and in 2,3 ie [2,5,8],[1,4,7] i wondering why concatenate not working me? use vstack >>> import numpy np >>> a=np.array(([1,2,3],[4,5,6],[7,8,9])) >>> b=a[:,1] # took 1 column >>> c=a[:,0] # again took 1 column >>> np.vstack((b,c)) array([[2, 5, 8], [1, 4, 7]]) use np.transpose if necessary

c# - List of opened connections in SignalR? -

how can list of opened connections signalr without sending them "ping" or manual registering them own list? update: or number of clients message sent hub. want know how many responses should wait (without waiting whole timeout). (since, signalr not support return values when calling clients hub, collecting results message clients sending hub.) clarification: assume signalr must know connections sending message. you can store user's id onconnected , remove on disconnect. see this example using database persist connected ids protected task onconnected(irequest request, string connectionid){ var context=new dbcontext(); context.connections.add(connectionid); context.save(); } protected task ondisconnected(irequest request, string connectionid){ var context=new dbcontext(); var id=context.connections.firstordefault(e=>e.connectionid==connectionid); context.connections.remove(id); context.save(); } then