Posts

Showing posts from May, 2015

javascript - How do I put a dialog box to pop up on any row I click -

i have code of table , want anywhere click on dialog box pop up. example, if have jazz 3 4 jazzy ram 5 7 ruth john 6 88 jujube that if click on 88 details john in dialog box or if click on ruth details ram. code <script type="text/javascript"> $('#tableitems').on('click', 'tr', function() { var row = $(this).find('td:first').text(); alert('you clicked ' + row); }); </script> <th style='width:75%;'>janurary</th> <th style='width:75%;'>february</th> <th style='width:75%;'>march</th> <th style='width:75%;'>april</th> <th style='width:75%;'>may</th> <th style='width:75%;'>june</th> <th style='width:75%;'>july...

c - Formatting file inputted text in char array? -

i have file.txt contains string of text. lets string is, without quotations "xdfs2\0dj\0\0aj" first put text char array, have accomplished using fopen , fread input text char *workingarray; my problem comes in form of trying print array. (using printf) want print array character character, each time reads '\0' want go new line.. output of workingarray be.. xdfs2 dj aj i'm trying accomplish in way right now.. for( i=0; <= length; i++ ) { if( workingarray[i] = '\0' ) { printf("\n"); } else { printf( "%c", workingarray[i]); } } now doesn't work because doesn't see first \0's '\0' '\' , '0' , 2 separate fields in array. i've tried searching '\' using '\\' in order compensate fact it's escape sequence gives me segmentation fault , core dumb when trying run it. i've tried making second array based off of first takes '\...

supervisord - Can i run multiple processes (each with different port) using systemd? -

i have following supervisord config(copied this answer ): [program:myprogram] process_name=myprogram%(process_num)s directory=/var/www/apps/myapp command=/var/www/apps/myapp/virtualenv/bin/python index.py --port=%(process_num)s startsecs=2 user=youruser stdout_logfile=/var/log/myapp/out-%(process_num)s.log stderr_logfile=/var/log/myapp/err-%(process_num)s.log numprocs=4 numprocs_start=14000 can same thing systemd? a systemd unit can include specifiers may used write generic unit service instantiated several times. example based on supervisord config: /etc/systemd/system/mydaemon@.service : [unit] description=my awesome daemon on port %i after=network.target [service] user=youruser workingdirectory=/var/www/apps/myapp type=simple execstart=/var/www/apps/myapp/virtualenv/bin/python index.py --port=%i [install] wantedby=multi-user.target you may enable / start many instances of service using example: # systemctl start mydaemon@4444.service article more exa...

postgresql - Remove two rows into single row in union query -

i have query - select id,fieldname value1,'' value2 tablename union select id,'' value1,fieldname value2 tablename it give output like-- id value1 value2 1 name 1 name 2 abc 2 abcx but trying display like- id value1 value2 1 name name 2 abc abcx in postgresql. can 1 suggest me how can it. unpivot work situation. use string_agg() : select string_agg(value1, '') value1, string_agg(value2, '') value2 ( select 'name' value1, '' value2 union select '' value1, 'name' value2 ) s; value1 | value2 --------+-------- name | name (1 row) aggregate functions string_agg() executed groups of rows. use group id : with a_table(id, col1, col2) ( values (1, 'name', 'name'), (2, 'abc', 'abcx') ) select id, string_agg(value1, '') value1, string_agg(value2, '...

java - Method wrapper for dealing with Exceptions? -

i'm implementing iterator , in order deal exceptions i'm using following pattern: actual work done in private hasnextpriv() method whereas hasnext() method deals exceptions . reason doing way because don't want litter hasnextpriv() try-catch blocks. @override public boolean hasnext() { try { return hasnextpriv(); } catch (xmlstreamexception e) { e.printstacktrace(); try { reader.close(); } catch (xmlstreamexception e1) { e1.printstacktrace(); } } return false; } questions: is there better way this? what name private method hasnextpriv() ? another way handle exceptions extract each part throws exception in small pure function handles each exception. , construct final result composing functions. optional<resource> open() { try{ //... return optional.of(resource); } catch { //.... return optional.empty(); } } optio...

string - Hamming distance (Simhash python) giving out unexpected value -

i checking out simhash module ( https://github.com/leonsim/simhash ). i presume simhash("string").distance(simhash("another string")) hamming distance between 2 strings. now, not sure understand "get_features(string) method completely, shown in ( https://leons.im/posts/a-python-implementation-of-simhash-algorithm/ ). def get_features(s): width = 2 s = s.lower() s = re.sub(r'[^\w]+', '', s) return [s[i:i + width] in range(max(len(s) - width + 1, 1))] now, when try compute distance between "aaaa" , "aaas" using width 2, gives out distance 0. from simhash import simhash simhash(get_features("aaas")).distance(simhash(get_features("aaaa"))) i not sure missing out in here. dig code the width, in case, key parameter in get_features() , give different splitted words. get_features() in case output like: ['aa', 'aa', 'aa'] ['aa', ...

Is it generally better to transform semi-structured into structured data on Hadoop if the possibility exists? -

i have large , growing datasets of semi-structured data in json files on hadoop cluster. data benign 1 of keys holds list of maps can change heavily in size, can vary between 0 , few thousands of maps each few dozen keys themselves. however data transformed 2 separate tables of structured data linked foreign keys. both narrow tables, 1 of them ten times long other. i either keep data in semi-structured format , use wide-column store hbase store or alternatively use columnar storage parquet store data in 2 large relational tables. it unlikely data format change, can't ruled out. i'm new hadoop , big data, of 2 possibilities preferable? should semi-structured data changed structured data if possibility exists , data format constant? edit: additional info requested rahul sharma. the data consists of shopping carts shopping software, variable length comes variable number of items in carts. data in xml format transformed json, not me, have no control on step. no re...

vsts - How do I push a Team Services git repository after build to an external git repository? -

Image
push different repository origin i have team services git repository clone , build when releasing project. after build, push build artifact different git repository location. git commands via command line tasks i'm able initialize git repo build artifact via command line task ( git init ), team service won't allow fetching, pulling , pushing via command line task. external git endpoint so, documentation says need use external git endpoint . don't see how can use endpoint push build to. am missing something? i did quick test didn't see issue. git repository can pushed external remote repository successfully. to reduce steps in definition, created batch script perform git action , upload batch script vsts source control: git init git add . git commit -m "vstsbuildartifacts" git remote add origin https://xxxxxxxxx git pull origin master git push origin master following steps(i skipped build steps, copied files build output file...

android - How to do or do nothing base on AsyncTask result? -

experts, my goal simple, input address, click button test url, if not expected result, toast info , nothing. if expect result, continue program. since can not use url in ui thread, used asynctask, problem is: though know result asynctak, how inform activity or nothing? want statement inside onclicklistener this: if (result not expected) return; else continue things. i cannot write above statement in onpostexecute, return onpostexecute(), not onclicklistener(). another is: if can pass result activity(namely onclicklistener()), when result arrives, ui thread run other codes, shouldn't before knowing result. in short, need url result decide how run remaining codes, therefore cannot use async task, should do? thanks. below example code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); btnconfirm.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { new xxx()...

java - Tomcat not reflecting changes in folder which is hosted outside webapps -

i have folder @ d:\myapp , hosted using tomcat myapp.xml @ catalina\localhost . myapp.xml content <context path="/myapp" docbase="d:/myapp"/> it's working excepted, it's not working when new file written using ftp @ d:\myapp , tried access using localhost:8080/myapp/newfile.png . but can access old files, after restarting tomcat once can able access newfile.png. please suggest me solution.

javascript - A .clone is not working properly nor is it returning array of names -

my code supposed have 3 input boxes , when click "add set", should clone 3 input boxes. when click "get company names" should return array of company names, being of values boxes. as stands, "add set" not work , not understand why. problem that, "get company names" returns object rather value .val suggest. `alert($("#workexperiencebox").find("input[id=companyname1]").val(""));` also, in fiddle, see code using duplicate boxes. extraworkepxerience div , workexperience first div inside of div. var workexperience = $("#workexperiencebox").clone(); $("#extraworkexperience").html(workexperience); the fiddle at. please help! fiddle: https://jsfiddle.net/tubbstravis/tmakdo1x/3/ id has unique, had made id's have used classes. other problem using html() instead of append() , result make entire html content of container replaced. var getnames = function(num) { alert($...

Email support javascript execution -

Image
i read on internet email client dont support javascript. then how google invite mail has yes | may | no buttons ? when inspect button not links java-script run upon clicking it. edit: in below image have show request generated when clicked on maybe button. these request not link request since initiator javascript

math - How to apply modulo operation on a char array in C? -

edited: i have big number c not have type natively. have use char array hold it. example, create 32-byte array. represents large number 2 ^ 256. unsigned char num[32]; // size number question. i want apply modulo operation on it, example, want mod big number small divisor , integer type result. int divisor = 1234; // note divisor smaller big number int result; // here // produce result // result = number mod divisor i not want use other library. how can it? to perform mod large number, use mod 1 unsigned char ( @bathsheba ) @ time. % c's remainder operator. positive operands has same functionality mod . unsigned mod_big(const unsigned char *num, size_t size, unsigned divisor) { unsigned rem = 0; // assume num[0] significant while (size-- > 0) { // use math done @ width wider `divisor` rem = ((uchar_max + 1ull)*rem + *num) % divisor; num++; } return rem; }

r - How do I create a pop up box in Shiny to get input data, which then carries foward in my Shiny app? -

i have app want ask question front in pop dialogue box, have question answered, have box disappear, , have app run. i have searched on week , have tried many things no avail. have tried readline() . have looked @ shinybs none of examples functioning. have looked tcltk2. while didn't errors, nothing happened include no dialogue box. here simple example of do. suppose want pop box ask, name? after name inputed, box closes, , app begins. perhaps app says, hello name. please me update code below. library(shiny) library(tcltk2) library(shinybs) #create pop box asking name. substitute value xxx below. ui <- shinyui(fluidpage( # application title titlepanel("hello xxx, how you?") ) ) server <- shinyserver(function(input, output) { }) # run application shinyapp(ui = ui, server = server) for completeness, here code wrote. gleaned link pork chop referenced. works, although parts still don't understand. library(shiny) logge...

I want to copy data in a CSV file to SQL SERVER using C# -

i trying out new standalone application development using c#. want copy data in csv file sql server database, seems else.i have been on problem whole day.please should me out. streamreader sr = new streamreader(@filepath); string line = sr.readline(); string[] value = line.split(','); datatable dt = new datatable(); datarow row; foreach (string dc in value) { dt.columns.add(new datacolumn(dc)); } while (!sr.endofstream) { value = sr.readline().split(','); if (value.length == dt.columns.count) { row = dt.newrow(); row.itemarray = value; dt.rows.add(row); } } using (sqlbulkcopy bulkcopy = new sqlbulkcopy(conn)) { conn.open(); bulkcopy.destinationtablename = "receipts"; foreach (var column in dt.columns) { ...

Synology NAS Backup to Azure Blob Storage - used space and billing -

i using azure blob storage backup synology nas. my used space on nas 810 gb used space in azure blob storage 2642gb. using standard io - block blob (gb) - locally redundant. does know why there such big difference in stored data? thanks, a there setting rotate backup data in hyper backup in synology nas. setup keep 227 restore points, data in azure blob storage growing every time backup taken. i've change settings in synology , it's free used storage.

json - Alternate to Like in jsonb postgres -

i have postgres table more 25m records, there have jsonb column called info. sample json format: { "username1":{"name":"somename","age":22,"gender":"male"}, "fathername":{"name":"somename","age":22,"gender":"male"} } i going find number of records match 'user%' key value. here query select count(1) tablename info::text '%user%'; this query working , getting result it, taking long time execute query in 25m records. is there way can optimize query or alternate method achieve it? please help. thanks in advance! as @klin pointed out, query give 0: select count(1) tablename info::text 'user%'; why because simple pattern match , don't have strings in info column begins 'user'. might have better luck '%user%' that's going awfully slow (unless have trigram extension enabled , index created) if ...

java - Android do something when an app is launched -

i'm wondering if there way detect if app running. on so, there related questions, old. so, wandering if android >= 5.0 can detect when app running. i don't want make app receives info because it's impossible; want build way receive information launcher. example: launcher should show overlaying popup when whatsapp launched on phone. can achieve this? if so, how?

excel vba - Error '1004': Unable to set the Visible property of the PivotItem class -

i got below code here: looping through report filters change visibility doesn't work solution marked working. after modifying according need, this: with pt.pivotfields(6) .clearallfilters if .pivotitems.count > 0 'goofy necessary set firstpi = .pivotitems(1) each pi in .pivotitems if firstpi.visible = false firstpi.visible = true end if 'don't loop through firstpi if pi.value <> firstpi.value itemvalue = pt.getpivotdata("[measures].[nr of cancelled]", "[characteristics].[reason]", pi.name).value rw = rw + 1 nwsheet.cells(rw, 1).value = pi.name nwsheet.cells(rw, 2).value = pi.visible if itemvalue < 2000 if pi.visible = true pi.visible = false 'error here end if else ...

docker registry - Deploying a modified Jenkins image in openshift fails -

i used "jenkins-1-centos7" image deploy in openshift run projects on jenkins image. worked , after many configurations, duplicated new image out of jenkins container. want use image used base further development, deploying pod on image fails error "errimagepull". on investigations, found openshift needs image present in docker registry in order deploy pods successfully. deployed app docker registries, when try push updated image docker registry fails message "authentication required" . i've given admin privileges user. docker push <local-ip>:5000/openshift/<new-updated-image> push refers repository [<local-ip>:5000/openshift/<new-updated-image>] (len: 1) c014669e27a0: preparing unauthorized: authentication required how can make sure modified image gets deployed successfully? probably answer need edits because issue can caused lot of things. (i assume using openshift origin? (opensource)). because see centos7 ...

java - WSO2 ESB - Payload not return on response -

Image
i'm exposed simple inbound endpoint filter. in first switch try payload not on response. second switch fault correct response (payload) send in response. how payload can send on request response ? <?xml version="1.0" encoding="utf-8"?> <sequence name="authuser" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> <property name="senha" scope="default" type="string" value="ah"/> <log level="full"> <property expression="get-property('request_payload')" name="request payload"/> <property name="text" value="recebi o request"/> <property expression="get-property('senha')" name="senha"/> <property expression="/soapenv:envelope/soapenv:body/mt_ordemservico_dealer_v2/ordemservico/id_chassi" name="id_chass...

apache - Multiples VirtualHost for Symfony3 projects in AWS development environment -

we have problem access multiple symfony3 projects in different folders , targeted same ip address in different ports on ec2, example: project1: 52.1.1.1:8080/login /var/www/html/projects/project1/ project2: 52.1.1.1:8181/login /var/www/html/projects/project2/ happens when entering project 1 (52.1.1.1:8080) displayed correctly, afterward when accessing project 2 (52.1.1.1:8181), fails, strangely deploys information project 1 . in scenario, when rebooting apache service , entering project2 (52.1.1.1:8181) displayed correctly, if after entering in project2 , enter project 1 (52.1.1.1:8080) information project2 displayed, instead of of project 1 . ports 8080 , 8181 open. apache configuration on server following: listen 8181 <virtualhost *:8181> documentroot "/var/www/html/projects/project1/web" directoryindex app.php <directory "/var/www/html/projects/project1/web"> require granted order all...

c# - How to pass back list of items as model from view to controller? -

Image
i have model (see below) , user should able @ single spend details (already working ajax , dropdown driven). once spend details loaded should able enter in either total amount details, or break down category (which coming different model (spendcategories) prepopulated). first iterate through categories pull them , each row map spendcategoryname spendcategory in spendbreakdown.cs. trying iterate , generate textarea per spendcategory name , send whole model (budgets). problem when run gives me argument out of range exeception on hiddenfor line in loop. need way save amounts , categories on post back. unfortunately new mvc , cannot change way model set up. working except piece. i had scrub of down privacy purposes please let me know if need clarification model public class budgets : financials { public spend spending { get; set; } public spenddetails spendingdetails { get; set; } public list<spendbreakdown> spendingbreakdown{ get; set; } } spend.cs publ...

what is mean by event loop in node.js ? javascript event loop or libuv event loop? -

Image
in node.js lot talk event loop, want know event loop talking about, javascript event loop or libuv event loop ? guess libuv event loop provides abstraction multiple operating system of multiplexing i/o ? right? if not please explain how stuff works? need internal knowledge, know event loop is, want know how connected? currently node uses the event loop provided libuv - namely default event loop: uv_default_loop() . see: an introduction libuv nikhil marathe: a default loop provided libuv , can accessed using uv_default_loop(). should use loop if want single loop. note: node.js uses default loop main loop. if writing bindings should aware of this. there linuv architecture diagram on design overview page in libuv api documentation: in past, libev's event loop used in node. see understanding node.js event loop mikito takada: internally, node.js relies on libev provide event loop, supplemented libeio uses pooled threads provide asynchro...

r - Error selecting columns in dataframe -

this easy question still not able figure out i'm wrong. i have following dataframe data3 <- structure(list(p1 = c("david skoch", "viktor troicki", "peter luczak", "simon stadler", "philipp petzschner", "jamie murray", "michal mertinak", "igor kunitsyn", "daniel munoz de la nava", "alexandre sidorenko"), p2 = c("lovro zovko", "dmitri sitak", "martin vassallo arguello", "sebastien de chaunac", "n.sriram balaji", "jaroslav levinsky", "stephen amritraj", "wesley moodie", "andrey golubev", "nicolas tourte"), date = structure(c(1167618386.44068, 1167619381.13208, 1167622892.30769, 1167626322.58065, 1167627172.88136, 1167629162.26415, 1167635959.322...

sql - Trying to Update one table with another table -

i have ledger table following 3 columns along others not included brevity: **gl_account id** | **gl_amount** | **gl_adjustmentamount** 9500 | null | null ... | ... | ... i have different adjustment table differing columns above except two: **gl_account id** | **gl_adjustmentamount** 9500 | 289.84 9500 | 9.63 9500 | 13646.11 9500 | 835.31 9500 | -210 9500 | -1019.02 9500 | -200 i need update ledger table include 7 new gl_adjustments includes 1 of values 289.84. here code. update ledgertable set [gl_adjustmentamount] = adjust.gl_adjustmentamount ledgertable genled full outer join adjustmenttable adjust on genled.gl_accountid = adjust.gl_accountid case 1 : update 1 account you can use if want 1 account : declare @accountid int...

oracle12c - What does: "error in materialized view refresh path" mean? -

i have query , when run can insert results fine table needs go into. but when run mv refresh: dbms_mview.refresh(mv, atomic_refresh => transactional) ; we error: error report - ora-12008: error in materialized view refresh path ora-01722: invalid number ora-06512: @ "link_od_ireport.r_mv_in_place", line 26 ora-06512: @ line 1 12008. 00000 - "error in materialized view refresh path" *cause: table snap$_<mview_name> reads rows view mview$_<mview_name>, view on master table (the master may @ remote site). error in path cause error @ refresh time. fast refreshes, table <master_owner>.mlog$_<master> referenced. *action: examine other messages on stack find problem. see if objects snap$_<mview_name>, mview$_<mview_name>, <mowner>.<master>@<dblink>, <mowner>.mlog$_<master>@<dblink> still exist. does know means? i've tri...

java - Android studio setting a hex color value for a button with code -

i change button color on click, have used following code button.setbackgroundcolor(#ff512e); did not work. have googled , couldn't find answer. i'm aware change in xml code need changed once button clicked. have set listeners , else needed need code set button color hex value on click. setbackgroundcolor(int) method takes integer argument passing string in code. use instead parse hex code of color int: button.setbackgroundcolor(color.parsecolor("#ff512e"));

Openlayers 3 - Interaction and pointermove -

i'm trying activate interaction when mouseover inside feature. it working so... problem if move mouse interaction keep active. is bug on ol3, or should in different way? code: http://jsfiddle.net/gmaq54dm/3/ olmap.on("pointermove", function (e) { if (e.dragging) { return; } var map = e.map; console.log(e.pixel); var feature = map.foreachfeatureatpixel(e.pixel, function(feature, layer) { return feature; }); var hit = (feature) ? true : false; console.log(hit); oldraw.setactive(hit); }); thanks this bug in application, not in openlayers. need make sure hit-detect features vector layer, not draw layer. change foreachfeatureatpixel function to var feature = map.foreachfeatureatpixel(e.pixel, function(feature, layer) { return feature; }, null, function(layer) { return layer == vectorlayer }); the last argument adds layer filter hit-detect features on vector layer. updated, working jsfiddle: htt...

javascript - Sending value from jquery to php not working -

i'm learning jquery , ajax. have tried following code, post value php jquery. doesn't work. can tell me mistake doing here, , solution. i want value1 printed php server side code, value being sent jquery based client side code. <html> <head> <title>practice 1</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> </head> <?php if (isset($_post['data'])) { $data = $_post['data']; print( "data is: $data" ); return; } ?> <body onload='process()'> <script type="text/javascript"> $.post(window.location, {'data': "value1"}, function (data) { $('#response').text(data); }); </script> </body> </html> you're trying output element doesn't exist '#response', process function missing...

html - Select text node with CSS -

i have following html markup: <h1> <div class="sponsor"> <span>hello</span> </div> world </h1> when use css selector h1 hello world . is there css selector can take text node? world in example? edited: i can't unfortunately change markup , have use css selectors because work system aggregates rss feeds. the current state of css can't this, check link: w3c the problem here content write screen doesn't show in dom :p. also ::outside doesn't seem work yet (at least me in safari 6.0.3) or doesn't generate desired result yet. check fiddle , check dom source: jsfiddle finally there attribute selectors a { content: attr(href);} , making css able read dom-node attributes. there doesn't seem innerhtml equivalent of yet. great tho if possible, whereas might able manipulate inner markup of tag.

coldfusion - How to use Coldfusoion MOD? -

i have code grabs events fullcalendar.js works fine. however, having hard time style in way in each column, has 2 events, breaks , goes next column. the code written in coldfusion , read can use mod. however, have tried if statement , counter track how many events , yet not go next column the following code using. trying target "more event" section when hits 2 events, breaks , goes next column: <!--- derived from: ---> <!--- https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3 ---> <!--- upcoming events ---> <cffunction name="dspdisplayevents"> <cfargument name="feedname" type="string" default="8c702325-155d-0201-11d851267d5b4b2b" /> <cfargument name="maxmonths" type="numeric" default="3" /> <cfargument name="groupdailyevents" default="true" /> <cfscript> var rs = ''; var subrs = ...

Podio API item revision difference doesn't return external_id for changed fields [UPDATE: fixed!] -

[edited add: api fixed , returns external_id expected] the podio api returns diff between 1 revision of item , documented here the diff returned api contains array of changed fields. each field can see field_id , label not field's external_id . is bug in api? official ruby gem api has property external_id never populated. is there way of getting field's external_id without making further (rate-limited) api calls? the podio api has been updated include external_id of field. just record, podio dev team implemented , released fix within 24 hours of understanding problem. yay them!

security - Using Android Fingerprint API to check if a new fingerprint has been added -

i doing testing of application uses android fingerprint authentication. app allows fingerprint authentication, possible add new fingerprint using lock screen pattern, , authenticate app using new fingerprint. notice google play store requires password reentry when new fingerprint has been added. my question is: how can make use of fingerprint api check see if new fingerprint has been added implement same behavior in own application?

Username/password authentication for Azure App Service: Mobile -

i'm following tutorial in order provide username/password authentication mobile server: http://www.newventuresoftware.com/blog/custom-authentication-with-azure-mobile-apps my server-side code this, using microsoft.azure.mobile.server.login nuget package: private jwtsecuritytoken getauthenticationtokenforuser(string username) { var claims = new[] { new claim(jwtregisteredclaimnames.sub, username) }; var signingkey = environment.getenvironmentvariable("website_auth_signing_key"); var issuer = request.requesturi.getleftpart(uripartial.authority); return appserviceloginhandler.createtoken(claims, signingkey, issuer, issuer, timespan.fromhours(24)); } this generating weird compiler error. call appserviceloginhandler.createtoken breaking compiler apparently misleading message: reference type 'jwtsecuritytoken' claims defined in 'system.identitymodel.tokens.jwt', not found. the type system.identitymodel.tokens.jwt.jwtsecuritytoken ...

c++ - pthread_cond_wait() not waking up on signal -

i trying wake thread queue process data, except it's not waking up. not sure if approach flawed. here code: main: struct threadoperationstruct _threadio; int main(int argc, char** argv) { // threads created here... } my waiting thread: void decompresslogfile::wait() { while (!_threadio.endevent) { pthread_mutex_lock(&lock); size_t queuesize = _threadio.decompresslogqueue.size(); if (!queuesize) { // prevent further thread execution fprintf(stdout, "decompresslogfile() thread sleeping...\n"); pthread_cond_wait(&_threadio.decompressqueuenotify, &lock); } else { fprintf(stdout, "processing compressed log files. queue size %lu\n", queuesize); /* * async tasks need go here... */ //bzip2_decompressfile(); _threadio.decompresslogqueue.pop(); } } fprintf(stdout, ...

c++11 - C++ get the first argument value in template parameter pack -

i have class class assetmanager { private: std::unordered_map<const std::type_info*, asset*> assets; public: assetmanager(); virtual ~assetmanager(); template <typename t, typename ...args> bool newasset(args... args) { //get path if(cached(path)) { return true; } auto asset = new t{ std::forward<args>(args)... }; assets[&typeid(*asset)] = asset; return *static_cast<t*>(assets[&typeid(t)]); } bool cached(const std::string& path) { for(auto asset : assets) { if(asset.second->getpath() == path) { return true; } } return false; } }; the first argument of every asset std::string path. i'm trying value , see if it's loaded in list. asset abstract class. class asset { private: std::string path; public: asset(const std::string& path); virtual ~asset() = default; virtual boo...

c# - how to stop insertion into database -

can stop inserting database if cells empty checking cell values are getting values database? might need check isdbnull(dt.rows[i][j]) . also, not sure if source of problem, checking if string equal value, can use string.equals() . in if statement, do if (isdbnull(dtrows[i][j]) or dt.rows[i][j].equals("")) { //code empty data } if you're not getting data db, wouldn't hurt check null or nothing value, not "" empty string value.

php - Laravel Sort Collection By Dynamic ID array -

i have following... $people = array(5, 2, 9, 6, 11); $people_collection = people::find($people); but when dump , die $people_collection collection ordered id asc, how can keep collection, in same order $people array? collections has sortby function takes custom callback: $people_collection = people::find($people) ->sortby(function($person, $key) use($people) { return array_search($person->id, $people); }); see the docs .

Try/catch in PowerShell when installing Chocolatey packages -

i've been trying create script installing chocolatey packages in powershell. works fine, want parse output chocolatey. i'm thinking like $package = "something want" try { $installcommand = "choco install $package" iex $installcommand -erroraction stop -warningaction stop } catch { #print error messages, i.e. $_.exception.message } i'm pretty new powershell, , i've tried figure out how use try/catch. i've tried try { $command = "choco install asdasdasdasdasdad" iex $command -erroraction stop -warningaction stop } catch { $message = $_.exception.message write-host $message } but gives me installing following packages: asdasdasdasdasdad installing accept licenses packages. asdasdasdasdasdad not installed. package not found source(s) listed. if specified particular version , receiving message, possible package name exists version not. version: "" source(s): "https://chocol...

Laravel: prevent user from accessing past and future events -

i have laravel application events, of happened in past, of them current , organised in future. table 'events' looks follows: +----+-------------+------------+-------------------+---------------------+---------------------------+---------------------+---------------------+ | id | category_id | event_name | event_description | event_startdate | event_closedate | created_at | updated_at | +----+-------------+------------+-------------------+---------------------+---------------------------+---------------------+---------------------+ | 1 | 1 | event 1 | event 1 | 2016-05-02 00:00:00 | 2016-06-30 00:00:00 | 2016-07-07 15:59:03 | 2016-07-08 12:26:07 | | 2 | 1 | event 2 | event 2 | 2016-06-02 00:00:00 | 2016-07-30 00:00:00 | 2016-07-07 15:59:03 | 2016-07-08 12:26:22 | | 3 | 2 | event 3 | event 3 | 2016-07-02 00:00:00 | 2016-08-19 00:00:00 | 2016-07-07 15:59:...

node.js - MYSQL Read-only DB in memory optimization -

i've created website biochem researchers allows users query specific genes , calculate various statistics between different sets of genes. the mysql db 16gb , read-only (our lab generated novel data , website portal view data) . i've performance tested website , realized db query slowest portion of app. want put entire db memory ran few problems accepted solutions: i have 8-core 32gb server use. option 1: set engine = memory a few columns of type mediumtext , exceed 64k row limit , refuse put memory engine option 2: increase innodb_buffer_pool_size this doesn't seem put data memory. checked used buffer pool using techniques described ( https://dba.stackexchange.com/questions/27328/how-large-should-be-mysql-innodb-buffer-pool-size ) see ~100mbs of used buffer pool. innodb_buffer_pool_size correctly set 24gb. option 3: create ramdisk , put db on there doesn't seem great option based on few posts. how should continue? please advise. have ch...