Posts

Showing posts from September, 2011

swift - How can I sort an array of strings based on the number of instances a string appears in an element? -

how can sort array of strings based on number of instances string appears in element? example: let str = "o" let arrayofstrings = ["hot", "only open on tuesdays", "people of earth"] //sort here //arrayofstring becomes ["only open on tuesdays", "people of earth", "hot"] import foundation let str = "o" var arrayofstrings = ["hot", "only open on tuesdays", "people of earth"] arrayofstrings.sort { return $0.components(separatedby: str).count < $1.components(separatedby: str).count } print(arrayofstrings) // ["hot", "only open on tuesdays", "people of earth"] note correct order if sort highest instances last. went least instances show this: string "o" , string "o" 2 different strings count in original array 1, 2, 2. if want compare strings case-insensitively have apply uppercase or lowercase operation compa...

python - What is the difference between the solution that uses defaultdict and the one that uses setdefault? -

in think python author introduces defaultdict . following excerpt book regarding defaultdict : if making dictionary of lists, can write simpler code using defaultdict. in solution exercise 12-2, can http://thinkpython2.com/code/anagram_sets.py , make dictionary maps sorted string of letters list of words can spelled letters. example, 'opst' maps list ['opts', 'post', 'pots', 'spot', 'stop', 'tops']. here’s original code: def all_anagrams(filename): d = {} line in open(filename): word = line.strip().lower() t = signature(word) if t not in d: d[t] = [word] else: d[t].append(word) return d this can simplified using setdefault, might have used in exercise 11-2: def all_anagrams(filename): d = {} line in open(filename): word = line.strip().lower() t = signature(word) d.setdefault(t, []).append(w...

bash - PS1 Style Formatting -

Image
i trying make bash profile cool, , outright stole example posted on internet (can't remember though; claim no credit it). managed of different quirks wanted work , got of color , syntax codes working on arch box, on macbook, terminal app shows huge space between bracket , number of files in pwd. appreciate in making pretty since kind of bums me out @ space. i have included ps1 below: export ps1="┌─[\`if [ \$? = 0 ]; echo \[\e[32m\]✔\[\e[0m\]; else echo \[\e[31m\]✘\[\e[0m\]; fi\`]───[\[\e[01;49;39m\]\u\[\e[00m\]\[\e[01;49;39m\]\[\e[00m\]]───[\[\e[1;49;39m\]\w\[\e[0m\]]───[\[\e[1;49;39m\]\$(ls | wc -l) files, \$(ls -lah | grep -m 1 total | sed 's/total //')\[\e[0m\]]\n└───▶ "

Android - How can I get the email from the online login and show it to next intent -

i created online login on mobile app, have online database, , use asynctask login. want display email user input app , display next intent how can that, how can pass email user input onpostexecute? here code in onpostexecute when user logged in. protected void onpostexecute(string result) { if (result.equals("login successfully!")) { toast.maketext(context, "welcome okshop", toast.length_short).show(); intent intent = new intent(context, main2activity.class); context.startactivity(intent); ((activity)context).finish(); } } and here login url else if (type.equals("login")) { string email = params[1]; string password = params[2]; try { url url = new url(login_url); httpurlconnection httpurlconnection = (httpurlconnection) url.openconnection(); httpurlconnection.setrequestmethod("post"); httpurlconnection.setdooutput(true);...

node.js - How to verify AWS Cognito Access Token on NodeJS -

i found example on how verify cognito access tokens python . how do same nodejs? there no sdk function this? so far have authorizecognitojwt(token) { const cognito_pool_id = 'ap-southeast-1_xxx' const cognito_jwt_set = { 'keys': [ { 'alg': 'rs256', 'e': 'aqab', 'kid': 'chkv+...=', 'kty': 'rsa', 'n': 'tkjexs...johc5q', 'use': 'sig' }, { 'alg': 'rs256', 'e': 'aqab', 'kid': 've...eb8dw6y=', 'kty': 'rsa', 'n': 'hw19h...0c9q', 'use': 'sig' } ] } const decodedjwt = jwt.decode(token, {complete: true}) console.log(decodedjwt) if (decodedjwt.payload.iss !== `https://cognito-idp.us-east-1.amazonaws.com/${cognito_pool_id}`) { ...

xml - Reading specific excel sheet into Python pandas dataframe without loading the whole workbook -

pd.read_excel(filepath, sheetname) , openpyxl.workbook(filepath) load whole workbook. have 30mb file on server , takes long time load. wondering if there method load specific sheet pandas dataframe without opening whole workbook. i have looked couple of methods. recently, converting workbook .zip , reading .xml files. know people have suggested using lxml. i'm not sure how go here. is there better way of doing this?

android - How to add floating action button one by one in Linearlayout -

Image
i'm developing attendance manager app. take attendance , i've create layout this i want make programatically. in below layout i've used add fab using xml. you can use recyclerview gridlayoutmanager achieve programatically, here example: http://abhiandroid.com/materialdesign/recyclerview https://inducesmile.com/android/android-gridlayoutmanager-with-recyclerview-in-material-design/ hope helps.

android - Is it possible to create widgets in NativeScript or React Native? -

i interested in learning react native or nativescript. i curious know if possible create widgets in either of these? i searched online lot not find solid information yet. any information on highly appreciated. thanks regards ayyaz

java - JSON to BSON ObjectID -

i want insert image files in mongodb gridfsbucket custom id. my code: public int uploaddocument(string file, string file_id) throws filenotfoundexception { gridfsbucket gridfsfilesbucket = gridfsbuckets.create(database,"files"); string path=file_dir.concat(file); inputstream streamtouploadfrom = new fileinputstream(new file(path)); gridfsuploadoptions options = new gridfsuploadoptions() .chunksizebytes(358400) .metadata(new document("type", "presentation")); gridfsfilesbucket.uploadfromstream(file_id, file, streamtouploadfrom); } i using below method files upload in gridfsbucket. openuploadstream(bsonvalue id, string filename, gridfsuploadoptions options) how custom bsonvalue pass id method?

c# - Two foreign keys in one table using SQL Server in asp.net webform -

i've created bidtable in i've used 2 foreign keys i.e id reg table & carid submitadd table. id reg table fetched comparison of username current session's username while carid fetched comparing query string id carid . the problem when use both of them in bidtable foreign keys, bidtable can not fetch both of data. when use them separately, example use id reg in bidtable foreign key, works perfectly. here's code: string cs = configurationmanager.connectionstrings["conn"].connectionstring; using (sqlconnection con = new sqlconnection(cs)) { sqlcommand cmdd2 = new sqlcommand("select * submitadd carid='"+ request.querystring["id"].tostring() + "'", con);//taking carid querystring con.open(); sqldataadapter sdda = new sqldataadapter(cmdd2); datatable dtt = new datatable(); sdda.fill(dtt); sqlcommand cmdd = new sqlcommand("select * reg username='"+ session["...

python - Selenium send_keys says: Element is not currently interactable and may not be manipulated -

i want send key login form. problem error says: element not interactable , may not manipulated this code: url = 'http://tx3.travian.ir' hero_url = 'http://tx3.travian.ir/spieler.php?uid=19865' driver = webdriver.phantomjs(r'phantomjs/bin/phantomjs') try: driver.set_page_load_timeout(15) driver.get(url) except: debug.printexception() wait = webdriverwait(driver, 10) username = wait.until(ec.visibility_of_element_located((by.name, 'name'))) password = wait.until(ec.visibility_of_element_located((by.name, 'password'))) username.send_keys('user') password.send_keys('pass') login_btn = driver.find_element_by_id('s1') login_btn.click() driver.get(hero_url) driver.close() what's wrong? you defined webdriverwait never use it from selenium.webdriver.common.by import selenium.webdriver.support import expected_conditions wait = webdriverwait(driver, 10) username = wait.until(expected_condition...

c# - VSIX package installation with registering custom library -

Image
i made visual studio extension using roslyn analyze , refactor source code. work on custom attribute declared in project in solution, , in analyzer, search attribute. project structure below: customanalyzer.base (class library) customanalyzer.base.mycustomattribute.cs (my attribute class) customanalyzer (analyzing , refactoring methods) customanalyzer.vsix (vsix package project) customanalyzer project has reference customanalyzer.base . want programmers able add customanalyzer.base.mycustomattribute annotation in top of methods after installing extension on visual studio . when install extension, cannot add reference customanalyzer.base since library not in assemblies list. how can register class library extension or framework assembly when extension has been installed? please sign class library project package project key.snk. right click project -> properties -> signing -> enable sign assembly -> click dropdownlist below -> browser... -...

tensorflow - How to know the shape of the input X which is a placeholder in TF -

i have code: x = tf.placeholder(dtype=tf.float32, shape=[none, 28, 28, 1]) w = tf.variable... .... z ... z tensor , calculated x, here know batch size of z, i.e., first element value of z, have tried z.get_shape()[0].value , tf.shape(z)[0]. both results none, how solve? thanks in advance. here example of how u can it: z = tf.variable(tf.zeros(shape=(2, 3, 4))) tf.session() sess: print sess.run(tf.shape(z)) since in tf in session need run session excute function want run !

php - laarvel query builder output is messy -

i'm new laravel framework , faced problem , when send query results in form : [{"visitors":3}] here code used result : <?php echo $q = db::table('visitors')->select('visitors')->get(); ?> is there missed ? this not best practice <?php echo $q = db::table('visitors')->select('visitors')->get(); ?> following mvc pattern, should query in controller, $q = db::table('visitors')->select('visitors')->get(); then pass $q in view. loop through $q results. if need specific result, $id = 3 , use where.

ios - Added device tag in storyboard file with Xcode 8.3 -

Image
this device tag added 1 of storyboard's files, didn't see before. i'm using xcode 8.3 . idea means? i'm wondering if should committed or not. <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> nothing serious. it's based on selected option of storyboard/xib:

javascript - "Page.ClientScript.RegisterClientScriptBlock" not working while "ScriptManager.RegisterClientScriptBlock" -

i trying figure why page.clientscript.registerclientscriptblock not working while scriptmanager.registerclientscriptblock do work my code using code: this.page.clientscript.registerclientscriptblock(gettype(), "headercomment", "<script>not working</script>", false); in past used work so tried solution , did find master page dont contain <form id="form1" runat="server"> when added form tag this.page.clientscript.registerclientscriptblock didn't work, , tried use scriptmanager.registerclientscriptblock(this.page, gettype(), "headercomment", "<script>working</script>", false); , worked. i prefer use page.clientscript.registerclientscriptblock , not scriptmanager.registerclientscriptblock way won't need change existing working code. i didn't find differences if there between those.. , scriptmanager.registerclientscriptblock changes cause change in application. ...

emacs - How to use Oh My ZSH within a Spacemacs shell? -

Image
context i have nice , beautiful setup on iterm2 (i'm using mac) default shell zsh , customized using oh-my-zsh , agnoster-fcamblor theme. issue as spacemacs user, as possible without leaving emacs. decided invoke terminal window inside of it, i'm used doing vim/tmux. this (in same directory): things i've checked apparently theme not being applied. this relevant part of ~/.spacemacs : (shell :variables shell-default-shell 'ansi-term shell-default-height 30 shell-default-term-shell "/bin/zsh" shell-default-position 'bottom) a few important things: $> echo $0 shows me zsh shell being used inside spacemacs. $> echo $ps1 shows me set , matches iterm2 . i tried sourcing configuration file use but, above fact suggests, being loaded. question how can apply oh-my-zsh theme inside spacemacs shell window?

cloudfoundry - error deploying CF on Openstack using bosh : "SecurityGroupNotFound\" -

i trying deploy cf on openstack using bosh . following documentation https://bosh.io/docs/init-openstack.html when execute : bosh create-env bosh-deployment/bosh.yml --state=state.json \ --vars-store=creds.yml -o bosh-deployment/openstack/cpi.yml \ -v director_name=bosh-1 \ -v internal_cidr=172.10.0.0/24 \ -v internal_gw=172.10.0.1 \ -v internal_ip=172.10.0.6 \ -v auth_url=https://mycontrollerip:5000/v2.0 \ -v az=test \ -v default_key_name=mykeypairname \ -v default_security_groups=[bosh,cf] \ -v net_id=3a374103-4b4a-49aa-b2e7-d113cb6939c3 \ -v openstack_password=mypassword \ -v openstack_username=myusername \ -v openstack_project=projectname \ -v private_key=/path/to/mykeypair.pem \ -v region=regionone \ -v openstack_domain=test \ -v tenant=projectname i error : stopping registry... finished (00:00:00) cleaning rendered cpi jobs... finished (00:00:00) deploying: creating instance 'bosh/0': creating vm: creating vm stemcell cid 'a8833ec1-7b3c-4904-a...

c# - Best way to send many requests in separate threads -

i have send many requests website, process response , return list of tuples. @ end combine lists one. when in loop takes long. how can use tpl (task parallel library) achieve shortest time? first case multithreading , don't know how should look. private static htmldocument htmlresult(restclient client, string querystring, int pagenumber) { var searchrequest = new restrequest("search/json", method.post); searchrequest.addparameter("query", querystring); if (pagenumber > 0) { searchrequest.addparameter("page", pagenumber); } var results = client.execute(searchrequest).content; var doc = new htmldocument(); doc.loadhtml(regex.unescape(results)); return doc; } private static ienumerable<tuple<string, string, string, list<string>, double>> resultslist(restclient client, string querystring, int pagenumber) { var doc = htmlresult(client, querystring, pagenumber); // process re...

PowerPoint VBA - Usings shapes as command buttons and changing colours -

i wondering if can help, i'm new vba , can't head around getting shape behave command buttons. i trying recreate game blockbusters in ppt 2013/2016. have main page hexagonal honeycomb grid numbered 1-25. if example click on hex 1 take slide qu 1. on slide of qu 1 have drawn 3 other hexagon 3 different colours...so when click on either 1 return honeycomb slide , change colour of qu 1 every colour hexagon pressed. can code??

testing - Figuring out which test case failed in Elasticsearch source -

after forking , downloading elasticsearch , tried running tests gradle check . execution took 2 hours , shown in stack blow there 1 error. [junit4] @ com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.eventbus.post(eventbus.java:215) [junit4] @ com.carrotsearch.ant.tasks.junit4.localslavestreamhandler.pumpevents(localslavestreamhandler.java:260) [junit4] @ com.carrotsearch.ant.tasks.junit4.localslavestreamhandler$2.run(localslavestreamhandler.java:122) [junit4] jvm j0: 0.82 .. 1838.85 = 1838.03s [junit4] execution time total: 30 minutes 38 seconds [junit4] tests summary: 4 suites, 479 tests, 1 suite-level error, 1 error, 14 ignored (14 assumptions) :distribution:integ-test-zip:integtestrunner failed cluster distribution_integ-test-zip_integtestcluster - node 0 log excerpt: (full log @ d:\code\elasticsearch\distribution\integ-test-zip\build\cluster\integtestcluster node0\elasticsearch-7.0.0-alpha1-snapshot\logs\distribu...

windows - Tooltip text truncated -

Image
i found out sometimes, text on tooltip not displayed. here's example such text: wwwww wwww, ww wwwwwwww wwwwwwwwww wwwwwwwwwwwww wwwwwwwww screenshot: my tooltip creation code (wtl): ctooltipctrl tooltip; toolinfo toolinfo; tooltip.create(window, null, null, tts_nofade); toolinfo = ctoolinfo(ttf_idishwnd | ttf_track | ttf_absolute, tooltip, 0, null, l"www..."); tooltip.addtool(&toolinfo); tooltip.sendmessage(ttm_settitle, (wparam)hicon, (lparam)l"title"); is known issue? appreciated. thanks! looks calling tooltip.setmaxtipwidth(maxint); fixes it. non-wtl version: sendmessage(..., ttm_setmaxtipwidth, 0, maxint);

Passed array inconsistent bahevior; C++ -

this question has answer here: using sizeof on arrays passed parameters [duplicate] 4 answers what array decaying? 7 answers i'm trying learn basic c++ , moment started think got grasp of pointers stumbled across problem: int sizeof(string texts[]) { return sizeof(texts); } int main() { string texts[] = {"apple", "banana", "orange", "watermelon"}; cout << sizeof(texts) << endl; cout << sizeof(texts) << endl; } and function returns 128 8 my question is: happening when pass array argument? why c++ forgets array? have tried dereference inside method ( return sizeof(*texts) ) returned 32 instead size of 1 string element, not whole array. possible want do? mistaken?

jquery - Set default option in php dropdown and retain when submitted query -

i have below code creates drop-down php. want achieve 2 things here. 1. want set 1 of option set default. may hard coded or selected query. 2. when hit button, should retain selected option. retrieve selected option using session data this: echo $print_version1[array_keys($print_version1)[0]]; drop-down code: $result = $conn->query("select distinct nx_version workflow1 order id desc"); echo "<form action='http://localhost/w_5aug/process.php' method='get'>"; echo "<html>"; echo "<body>"; echo "<p></p>"; echo "<center>"; echo "<strong> select base verison compare : </strong>"; echo "<select name='nx_version' id='nx_version'>"; while ($row = $result->fetch_assoc()) { $nx_version = $row['nx_version']; echo '<option>'.$nx_version.'</option>'; } ...

vba - Store DigitalPersona u.are.u 4500 Serialized FingerPrint Template in ms access ole object database using vb6.0 -

right doing project involve authentication fingerprint. use digital persona u.are.u 4500 reader sdk. samples included in sdk helpfull after creating project , ready store template in ole object column got stuck. aware need insert template byte array or blob don't know start. can guys me out or point me links i've never visited? i using visual basic 6.0 , ms access 2003 database; know it's old still requirement of project i'll stick that.

sockets - Integration testing for a Spark Streaming application -

i trying write integration test complex spark streaming application, has different input , output support. after starting application, rest call made submits json containing various config params , component info. while trying write test case socket input , console output pretty confused in how test application whole i.e submit streaming data socket , comparing output console. the application produces output on console via dataframe.println approach integration testing?

Python requests equivalent of following curl code -

could please inform python requests equivalent of following curl code upload file knack? part after -f option. thank you curl -x post "https://api.knack.com/v1/applications/your-app-id/assets/file/upload" \ -h 'content-type: multipart/form-data' \ -h 'x-knack-rest-api-key: your-api-key' \ -f "files=@/path/to/your/file.txt" use requests.post files , headers . curl code equivalent to: url = "https://api.knack.com/v1/applications/your-app-id/assets/file/upload" files = {'files':open('/path/to/your/file.txt', 'rb')} headers = {'x-knack-rest-api-key': 'your-api-key'} r = requests.post(url, headers=headers, files=files) when using files argument, requests creates necessary headers automatically don't need have "content-type" or "content-length" in headers .

html - Height of <li> elements equal to height of <navigation> -

body { margin: 0; } .header { width: 80%; height: 20%; margin-left: 10%; position: fixed; top: 0; border-style: solid; border-width: 1px; background-color: green; } .image { width: 20%; height: 100%; float: left; border-style: solid; border-width: 1px; } .navigation { width: 79%; height: 100%; float: right; text-align: right; border-style: solid; border-width: 1px; } li { height: 100%; display: inline; border-style: solid; border-width: 1px; background-color: blue; } <div class="header"> <div class="image"> image </div> <nav class="navigation"> <li> 1.0 main menu </li> <li> 2.0 main menu </li> <li> 3.0 main menu </li> </nav> </div> with code above create <header> consisting of <image> , <navigation> . <image> , ...

javascript - Linking Web UI objects to my REST services -

i'm jumping world of web development. i've built backend code, i've built external rest api gives me access code, , i'm moving onto front end. what's efficient , elegant way consume rest api front end? i have rest api methods: public class externalcontroller : apicontroller { [httpget] [route("getstringformats")] public httpresponsemessage getstringformats() { basicresponse<list<string>> response = new basicresponse<list<string>>(); httpstatuscode status; try { response.starttime = datetime.now; response.result = stringformatters.getformatkeys(); // returns list of strings response.status = true; status = httpstatuscode.ok; } catch(exception exc) { response.status = false; response.exceptionmessage = exc.message; response.exceptiontype = exc.gettype().name; st...

javascript - Attempted to switch from webpack v1 syntax to webpack v3 and encountered a weird compilation error -

i working on reactjs login screen project , first encountered issue webpack (re: compilation issue react login screen ) @andrew li( https://stackoverflow.com/users/5647260/andrew-li ) correctly prompted switch webpack v1 syntax webpack v3 syntax. this resulting config code: https://gist.github.com/jqed-xuereb/8134002fdfb697e34a855e0394969ffc upon compiling , running code using webpack index.js run.js following error unexpected token in line doesn't exist in code. precisely 1 line under final line. error: c:\users\jake\command line work\learnd\iteration 0\app\frontend>webpack index.js run.js c:\users\jake\command line work\learnd\iteration 0\app\frontend\webpack.config.js:143 }); ^ syntaxerror: unexpected token } @ createscript (vm.js:56:10) @ object.runinthiscontext (vm.js:97:10) @ module._compile (module.js:542:28) @ object.module._extensions..js (module.js:579:10) @ module.load (module.js:487:32) @ trymoduleload (module.js:446:12) @ function...

c - Iterate through string and store numbers in array -

i iterate through string 1.3.6.1.2.1.2.2.1.10.1 , store numbers in array. code works numbers between 0-9 not greater 9 because iterate 1 step , scan number. how can store numbers, not in current output : 1 3 6 1 2 1 2 2 1 10 0 1 (without linebreak)? int main(int argc, char *argv[]) { //char * string = "1.3.6.1.2.1.2.2.1.9.1"; /* ok */ char * string = "1.3.6.1.2.1.2.2.1.10.1"; /* nok */ static int oid_val_arr[256]; char *oid_tmp = string; int idx = 0; while (*oid_tmp) { int number; if (sscanf(oid_tmp, "%d", &number) == 1) { oid_val_arr[idx] = number; idx++; } oid_tmp++; /* problem */ } for(int = 0; < 12; i++) printf("%d\n", oid_val_arr[i]); } should use strtok() ? in code, change this: if(sscanf(oid_tmp, "%d", &number) == 1) to this: if(sscanf(oid_tmp, "%d%n", &number, &len) ...

c - How can i save space in array which is not being used? -

if create array of size 10 , 2 elements stored in array remaining spaces gets wasted. how can solve problem? (by data structure) you use simple linked list instead of array, or if need use array, should use realloc() , shrink array use 2 cells, instead of 10. , this: #include <stdio.h> #include <stdlib.h> int main(void) { int* ptr = malloc(10 * sizeof(int)); ptr[0] = 4; ptr[1] = 13; ptr = realloc(ptr, 2 * sizeof(int)); printf("%d %d\n", ptr[0], ptr[1]); return 0; } output: 4 13

uisearchbar - Swift 4 - iOS 11 Search bar scope won't appear as it should -

Image
i have app works nice , without problems on ios 10 ios 11 , xcode beta 5, have strange problem search bar scope scope bar seems cut bottom. (it same versions of xcode beta , ios 11) really glad if can put me in right direction. thanks above can see see when press hamburger menu button. no problem here.. searchbar has scopebar shows when clicked on.i did not set show programatically.but guess default behaviour when scope button titles set. the problem: when click on searchbar enter information see screen above. on ios 10 had no problems. now, ios 11, whatever cannot make work works on ios 10. search scope bar shows cut bottom. this how shows in ios 10 , want in ios 11. storyboard view of screen i pasting relevant code here. class slidemenuviewcontroller: uiviewcontroller,uitableviewdelegate,uitableviewdatasource,uisearchcontrollerdelegate,uigesturerecognizerdelegate{ let searchcontroller = uisearchcontroller(searchresultscontroller: nil) @ibout...

ios - New to git and keep getting the error when I make a new repository via Xcode -

i keep getting error when make new repository: failed parse config file: invalid configuration key (in /users/username/.gitconfig:3, column 0) (-1) in terminal: git init fatal: bad config line 3 in file /users/username/.gitconfig line 3 email line , accurate try update configuration file, in terminal write: git config --global user.email example@email.io and in case update username: git config --global user.name "yourusername"

android - How this error can be resolved? -

Image
the app crashes out click hit button. following things being shown in logcat. posting required files. here logcat: 08-20 19:10:22.656 6198-6198/com.example.sambal.jasonparsingdemo e/androidruntime: fatal exception: main process: com.example.sambal.jasonparsingdemo, pid: 6198 java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.textview.settext(java.lang.charsequence)' on null object reference @ com.example.sambal.jasonparsingdemo.mainactivity$1$1.onresponse(mainactivity.java:49) @ com.example.sambal.jasonparsingdemo.mainactivity$1$1.onresponse(mainactivity.java:45) ...

Reactjs setstate by field -

in react js component have code this.state.author[field] = value; in console got warning: not mutate state directly. use setstate() how put author [] in setstate? if field variable holds key, can this: this.setstate({author: {...this.state.author, [field]: value}})

c# - How to create temp table by using Fluent NHibernate -

is there solution create temp table existing entity? suppose has employee class mappings , want have second table in database named "tmp_employee", same columns, keys etc.. don't want create class tmp_employee mappings. use sql loader doesn't supports update. creating temp table based on mappings of existing entity, can it.

c# - Outlook Automation Namespace,addstore -

i have user outlook crash when call line in application. namespace.addstore(filepathofpst); i error message of rpc failed. line of code works every other user , can never figure out what's causing user fail . does have inkling on may causing ? pst isnt corrupted , can accessed fine.

actframework - How to run an Act framework application without using intelliJ IDEA -

i started act framework not want use intellij idea. how run app on windows , on linux using cli? start act in development mode using mvn clean compile exec:exec and in production mode with mvn clean package cd target/dist unzip * ./start i got link in gitter channel act

ajax - This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. -

i want take both 'blog entry' , 'blog entry photo' controller ajax. when taking 'blogentry' there isnt problem ,on other hand, when taking both of them (blogentry , blogentryphoto), there problem: "this request has been blocked because sensitive information disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior allowget." i think problem in 'blog entry photo' because has photopath column "/content/img/blog/25052017_2334_400x400.jpg". used jsonresult doesnt work return json(new { success = true, blogentries = blogentries, blogentryphotos = blogentryphotos}, jsonrequestbehavior.allowget); what should do? finally, solved issue arising photopath data. first, @ controller, data of both blogentry , blogentryphotos serailized @ view data parsed object. controller list<blogentry> blogentries = _blogentryrepo.getall(x => x.isactive.value && x.placemarkerid == plac...

java - How to include opencv native library while exporting to jar -

i preparing jar compares images , returns results accordingly. using opencv comparing same. when exported jar , provided collegue consume in android application, getting error on following line. system.loadlibrary(core.native_library_name); on checking, found library being consumed form local path on system. how can pass following library in jar, every once can consume it. also not sure, whether work then, system.loadlibrary tries consume java paths in system. alternative load library classpath? open suggestions. native libraries depend on libraries outside of jvm, , can not added in portable way java application. being said: can still include file in jar opening jar file, zip, add file in, , reference path (ex: /yourlibs/bla.lib loading jar be: nativeutils.loadlibraryfromjar("/yourlibs/bla.lib"); you might miss lot of dependencies , have of manually reading docs, scanning code , testing code, , might still limited os installations.

Dumping strings out of executable -

(to honest, don't know programming, please tell me if wrong place ask!) my question how string dump this out of executable / dll. tried didn't me dump linked 1 hashes , bit of got not helpful me... program should used , how have it? i'd grateful every get!

javascript - Mongoose conditional TTL for document -

is there way set expiresat index documents, depending on current document state? yes, there is. need set both partialfilterexpression , expiresat indexes. works @ mongodb 3.2+ code below remove document after 24h if payed property equal false : let billingschema = new mongoose.schema({ _id:type:number, summ:{ type:number, required:true }, description:string, payed:{ type:boolean, default:false, index:true }, ownerid:{ type:mongoose.schema.types.objectid, ref:'user', index:true } },{timestamps: true,_id: false}); billingschema.index({createdat: 1},{expireafterseconds: 24*60*60,partialfilterexpression : {payed: false}});

docker - Mule project is not showing on http://0.0.0.0:8080 after deployment in docketed container -

mule container running per following log :details in code block. info 2017-08-20 14:53:50,580 [wrapperlistener_start_runner] org.mule.runtime.module.launcher.mulecontainer: ********************************************************************** * mule runtime , integration platform * * version: 4.0.0-beta.4 build: c03a2009 * * mulesoft, inc. * * more information go https://developer.mulesoft.com/ * * * * server started: 8/20/17 2:53 pm * * jdk: 1.8.0_131 (mixed mode) * * os: linux (4.4.0-1022-aws, amd64) * * host: b2c75bd67158 (172.17.0.2) * * mule services: * * - mule-service-oauth-1.0.0-beta.4.zip ...

Should I use plain Python code or Celery? Django. -

i have heavy function (a lot of calculations done) outputs individual number each user in django project. number changes little on time minimize server load thought running function once day, save output , reference output. know these kinda things handled celery package requires lot of site packages , modules thought writing simple function like: x0 = #last.time function called x1 = datetime.now if x0-x1 > 1 day: def whatever(): .... x0 = datetime.now return .... i keep code clean , not install packages not required know if there downsides "just" using python or gain when celery . task not need asynchronous don't care that. there clear "use case" when celery should used , when not? there performance loss/gain? i hope can explain properly. celery clear winner explain pros , cons. pros : you can control celery django easily. running celery task, cancelling task, checking state/progress of task can done within django. a pe...

storefront - How to change display of variable products on Woocommerce archive-product page -

i using storefront theme (downloaded few days ago newest version) , want quite simple: on archive-product page want display product name of list of variable products (all shoes) , along 2 custom fields attached product post type. all goes simple products. can edit shown through theme-child folder/woocommerce/loop/price.php. issue appears turn product variable product. when that, custom fields disappear, , see beneath product button says "select option" i have been looking hours find correct template/hook fix cant find it... have no idea :( hope ome

c++ - Poof that shrink_to_fit or swap provide a guarantee to release vector's memory -

this question has answer here: c++ delete vector, objects, free memory 4 answers can provide proof 1 of following approaches provide guarantee free vector's memory in platform independent manner? vector<double> vec; //populating vec here cleaning up: 1- shrink fit approach vec.clear(); vec.shrink_to_fit(); 2- swap approach vector<double>().swap(vec); creating vector using new unlikely think you'd want either. std::vector implementations "guarantee" allocate enough memory hold requested number of elements at minimum . latter important because asking os or runtime more memory when need grow vector expensive operation may potentially trigger element copy well. reason, lot of implementations use heuristics determine how big allocation going when vector has grow size. example, 1 implementation i'm familiar doubl...

node.js - Access form data node js -

Image
i building api accepts form data(variable or image). passing following i rendering req , getting { "------webkitformboundarykjcufndj9nu9uepk\r\ncontent-disposition: form-data; name": "\"attachment_type_id\"\r\n\r\n0\r\n ------webkitformboundarykjcufndj9nu9uepk\r\ncontent-disposition: form-data; name=\"firstname\"\r\n\r\nimrn\r\n ------webkitformboundarykjcufndj9nu9uepk\r\ncontent-disposition: form-data; name=\"lastname\"\r\n\r\nahmd\r\n------webkitformboundarykjcufndj9nu9uepk--\r\n" } if render req.body.attachment_type_id , blank response. how can data value attachment_type_id ? have check attachment_type_id before uploading image. you can multer . install multer running npm install --save multer in server.js or app.js var multer = require( 'multer'); var upload = multer(); // parse json data app.use(bodyparser.urlencoded({extended: true})); app.use(bodyparser.json()); // multi form data a...

java ee - Replace path parameter dynamically -

i have @provider should replace path variable this: @provider @priority(value = 1) public class securitycheckrequestfilter implements containerrequestfilter { @override public void filter(containerrequestcontext requestcontext) throws ioexception { //code requestcontext.geturiinfo().getpathparameters().putsingle("userid", somenewuserid); } } when debug it, path variable "userid" seems replaced, @ endpoint later in workflow (for example /user/{userid} ), old value appears again. nothing replaced. no information behaviour in latest resteasy doc, in very old resteasy doc , there information, getpathparameters() returns unmodifiable list. if unmodifiable, why can replace value within provider then? nevertheless, value not replaced. how can overwrite existing path parameter new value? (sure, add new userid header parameter , fetch information later in endpoint, that's not solution) i have solution now. it's li...

less - Loading a page correctly with Masonry + LessCSS -

i had problem masonry plugin causing function when viewport being changed, meaning masonry boxes invisible until resize browser window. after boxes not olny visible masonry works expected. i resolved problem using regular css again styling, , not less css anymore had intended. but able use both? (it doesn't seem it's simple 'reorder how scripts being loaded' kind of thing) funnily when use jsfiddle , implement less css there, there no problem. maybe can tell me jsfiddle fix issue? https://jsfiddle.net/rcygo5fy/ code "solution": since solution hassle code , compiling css on every load heavy, client-side, best solution leave less out of end result , use development less-to-css-rendered file actual usage. css masonry timing problem goes away.

css - How to fix the arrow button -

how fix arrow button attached i'm using http://jsfiddle.net/shpoont/3ca4x/ codes. cannot change html codes, generate program. can override css codes. help. short list of button code given below: <button id="flowselectusersbtn" class="btn btn-progress progress-active" href="#"> <span class="hidden-xs ng-binding">select users</span> </button> [![arrow button][1]][1] here css codes: .progress-active { position: relative; padding-left: 18px; padding-right: 18px; } .progress-active { padding-left: 36px; } .progress-active:before, .progress-active:after { content:""; position: absolute; top: 5px; width: 22px; height: 22px; background: inherit; border: inherit; border-left-color: transparent; border-bottom-color: transparent; border-radius: 0px 4px 0px 0px; -webkit-border-radius: 0px 4px 0px 0px; -moz-border-radius: 0px 4px 0p...

node.js - How to upload an image along with other text fields in angular 2.x or 4.x, serve in node js and save to mongoDB along with the image path -

am having weird problem, , ave seen fellow developers asking on same, have several modules hundle uploading files, , yes work fine, problem how add text fields along file upload. lets want angular 2 blog obliviously want add title, description, body or main content , add image accompany blog post. in case using uploader ng2-file uploader after image uploaded in specified folder /uploads next???? how save image path along text field blog post in mongodb when display article world see , everthing typed appears including image uploaded..a example twitter, choose image , add text , boom! retrieved image , text u typed..i have searched , see blogs text fields , no ways of including , serving images.any appreciated. thank you.. my angular 2 html code.. <h1>post database</h1> <form class="well" (submit)="addpost($event)"> <!--text field input--> <div class="form-group"> <input type="text" [(...