Posts

Showing posts from 2015

c++ - Producer-consumer based multi-threading for image processing -

update: have provided reason of problem , solution in answer below. i want implement multi-threading based upon producer-consumer approach image processing task. case, producer thread should grabs images , put them container whereas consumer thread should extract images container thread. think should use queue implementation of container . i want use following code suggested in so answer . have become quite confused implementation of container , putting incoming image in producer thread. problem: image displayed first consumer thread not contain full data. and, second consumer thread never displays image. may be, there race situation or lock situation due second thread not able access data of queue @ all. have tried use mutex . #include <vector> #include <thread> #include <memory> #include <queue> #include <opencv2/highgui.hpp> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> mutex mu; struct threadsafecontai...

css - CSS3 selector matching value beginning with "[attribute^=value]" is not matching value that has space(s) after quotation -

the div[class^="test"] selector not match element in markup if element class=" test-something" (the intended selector had been generated on backend.) the div[class^=" test"] is not option. any suggestions? what did there ^= is: 'begins with..' div[class^="test"] { } which work on this: <div class="test and-some-class"></div> <!-- if first string in class matches "test" --> <!-- so, class=" test something-else" won't work you have use css selector: 'contains..' div[class*="test"] { } which work on <div class="class test something-else"></div> <!-- class name can anything. "test" can anywhere --> reference css3 attribute selectors: substring matching

Is Alfresco 5 compatible with JDK 1.5? -

i using alfresco 5 jdk 1.5. below jars using alfresco-opencmis-extension-0.3 alfresco-web-service-client chemistry-opencmis-client-api-0.10.0 chemistry-opencmis-client-bindings-0.9.0 chemistry-opencmis-client-impl-0.10.0 chemistry-opencmis-commons-api-0.10.0 chemistry-opencmis-commons-impl-0.10.0 i have configured parameters , i'm getting error below while getting repository -- ( repositories = factory.getrepositories(parameter) ) org.apache.jasper.jasperexception: org.apache.chemistry.opencmis.commons.exceptions.cmisconnectionexception: unexpected document! received: html document @ org.apache.jasper.servlet.jspservletwrapper.handlejspexception(jspservletwrapper.java:491) @ org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:419) @ org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:313) @ org.apache.jasper.servlet.jspservlet.service(jspservlet.java:260) @ javax.servlet.http.httpservlet.service(httpservle...

r - Turning into data.frame into a list based on ids -

i have data.frame: df <- data.frame(id=c(1,1,2,2), event=c("merged", "discussed", "merged", "discussed")) now want turn list, in such way list contains 2 entries - 1 each id (i.e. 1 , 2), , records correspond entries, such: list of 2: [1] name: "1", data.frame id event 1 1 merged 2 1 discussed [2] name: "2", data.frame id event 1 2 merged 2 2 discussed obviously looking generalizable solution scale beyond minimal example. try split split(df, df$id)

Unrecognized DB Format-Excel VBA to Access Database -

im using .accdb file , connecting following code, has worked me multiple times, don't know why corrupting file time. dbpath = activeworkbook.path & "\waitanalysisdb.accdb" tblname = "wait_data_table" strcon = "provider=microsoft.ace.oledb.12.0;data source='" & dbpath & "';" conn.open strcon does "unrecognized format" access error occur due error in connection string, or sql statement inserting records well? thanks here's code, if cares through it. in loops build sql statemetn (rcddetail variable), have if statement, says if there blank in column a, use row above isnt blank. dim conn new adodb.connection, rs new adodb.recordset, dbpath string, tblname string dim rngcolheads range, rngtblrcds range, colhead string, rcddetail string dim ch integer, cl integer, notnull boolean, strcon string, lr integer dim currentdate string dim strdbcheck string 'code checks if there records date in db ...

java - Appscan source edition - SQL Injection -

i using appscan source edition java secure coding. reporting sql injection in application. issue generating query dynamically in code cannot use prepared statement. instead have e esapi.encoder().encodeforsql(new oraclecodec(), query) . appscan not consider mitigate sql injection issue. final string s = "select name users id = " + esapi.encoder().encodeforsql(new oraclecodec(), userid); statement = connection.preparestatement(s); this code additionally not work esapi.encoder() how can resolve issue? what should is final string s = "select name users id = ?" statement = connection.preparestatement(s); statement.setstring(1, userid);

jquery - JTable Repaint Parent from a Pop-Up -

got popup used below javascript function when closed. <script> window.onunload = refreshparent; function refreshparent() { window.parent.location.reload(); </script> however, need on parent refresh/repaint jtable hooked on div tag named site. $('#site').jtable({ i tried: window.parent.$('#site').repaint(); // , window.parent.location.$('#site').repaint(); // , parent.$('#site').jtable('repaint'); however, nothing refresh data. need refresh jtable since there several back-end changes happened can not keep track of. just wondering if there way reloaded data in jtable.

javascript - Highcharts live data not updating after changing PHP variable -

i've got live updating highchart on page, index.html, calls php script, datatest.php, parse csv file, outputs result json , adds new point on chart: $.ajax({ url: 'datatest.php', success: function(point) { var series = chart.series[0], shift = series.data.length > 20; // shift if series longer 20 // add point chart.series[0].addpoint(eval(point), true, shift); // call again after 1 second settimeout(requestdata, 1000); }, cache: false }); the basic php script stores "line" session variable, each time script called, parses next line of csv file. csv file has 2 columns, 1 "hi" , 1 "lo". i'm trying add couple of buttons page can dynamically change column of csv file php script returning. code these buttons below: <form method="post" action ="datatest.php"> <input type="submit" name="highwind" value="h...

jpa - Acceptance of specific values using Hibernate -

if use annotation @size(min = 1, max = 50) in hibernate, can write string database @ least 1 , @ 50 characters. but need restrict possible values 2 numbers: 12342 , 13409 . is there annotation allows this? you can use pattern annotation example: @pattern(regexp="12342|13409") private string string; otherwise can write custom constraint. see documentation further information. https://docs.jboss.org/hibernate/validator/5.2/reference/en-us/html/chapter-bean-constraints.html#section-builtin-constraints https://docs.jboss.org/hibernate/validator/5.2/reference/en-us/html/validator-customconstraints.html

java - Text based game with a separate timer loop? -

i have started java coding short course @ university 5 months ago. have learnt quite amount of things regards java coding, still lacking in other things such threads, handling exceptions, or making jframe games. decided embark on text based game learn , figure out how game loop should work (kind of), , how logic should work (still, "kind of"). game wrote runs if-else commands, displayed screen, type in command of option want pick, , bumps next menu, standard of course. run these if-else statements within nested for loops. my nested for loops looks following: // example, they're lot more cluttered // in actual source code. mainmenu.writeoutput(); reply = keyboardinput.nextline(); (int = 0; <= 10; i--) { (int ii = 0; <= 10; i--) { if (reply.equalsignorecase("/help") { system.out.println("here have separate call class file (excuse me, f...

ios - Does Microsoft OneDrive allows a buisness parter to connect with it without Oauth Authentication -

we want integrate our mobile app onedrive , not want user explicitly login onedrive. the flow want like. our app authenticate user based on credentials stored in our organization's ldap. once user authorized want enable him onedrive account through our application. short answer, no. oauth 2.0 public api authentication, stated on onedrive api documentation . you can verify authorization against ldap first, user going have log in authorize access onedrive @ point, somewhere.

c# 4.0 - Add JavaScript code dynamically with JSON in Asp.net - JVector Map -

i using jvector map , marking locations on map using markers . according documentaiton following code can used mark locations. markers: [ { latlng: [53.3574436, 9.9076650], name: 'some city' }, { latlng: [53.3574436, 10.2127204], name: 'another city' }, { latlng: [56.5611120, 24.0300030], name: 'one more city' } ] in case not sure how many locations need mark. times 3, times 5. want know is, possible generate code inside markers : [ ] dynamically json. or may other way? you add code clientscriptmanager.registerclientscriptblock see: https://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptblock(v=vs.140).aspx or inline in markup <% %> tags.

javascript - strange error of jquery sibling('.class') in my case -

Image
console.log((this).sibling('.advanceoptwrap')); above code return error of uncaught typeerror: $(...).sibling not function. my dom this var advanceoptwrap = jquery(this).sibling(".advanceoptwrap"); console.log(advanceoptwrap); //alert(advanceoptwrap);

google chrome extension - IndexedDB range limits -

i'm using indexeddb store person's city, email id , created_at. want people in city valid email , sort created_at date. i have compound index query so: var city = "chennai"; var index_name = "city, " + "email, " + "created_at"; var index = store.index(index_name); var boundedkeyrange = idbkeyrange.bound([city, "", 0], [city, ??, ""]); index.opencursor(boundedkeyrange, "prev").onsuccess = function(e) { var cursor = e.target.result; if (cursor) { // check if email valid , add array } else { // resolve promise } } the problem have don't know how set 'upper range' email id's since @ special character i'm not sure set upper range have email ids in query. thank you deepak the upper bound of string can taken '\uffff' or [] . anyways, query not work because have 2 range query, "email" , "cr...

java - Get the list of all files under the folder resources -

my unit test project structure looks this: . └── src └── test ├── java │ └── foo │ └── mytest.java └── resources ├── file1 |-- ... └── filen in mytest.java , list of files under src/test/resources/ : file[] files = get_all_resource_files(); how in java? try code: file selected_folder = new file(system.getproperty("user.dir")+"/src/test/resources/"); file[] list_of_files = selected_folder.listfiles(); for viewing files under particular directory have selected files... can this... for(int i=0; i<list_of_files.length; i++) { system.out.println(" file number "+(i+1)+" = "+list_of_files[i]); }

java - Decrypt AES256 encrypted file and save it in the phone -

i'm downloading file stored on remote server, try decrypt using jncryptor , , goes except file have downloaded , store in phone external storage corrupted , cannot open it. can tell me im going wrong? im trying inputstream file, decrypt it, , save file on external storage. thanks here code: private void downloadfile() { final string file_url = "https://www.google.com"; final string pass = "password"; new asynctask<void, void, void>() { @override protected void doinbackground(void... voids) { log.d(tag, "starting"); jncryptor cryptor = new aes256jncryptor(); int count; try { url url = new url(file_url); urlconnection conection = url.openconnection(); conection.connect(); // useful can show tipical 0-100% // progress bar ...

c# - Interactive logon: Prompt user to change password before expiration -

how can "interactive logon: prompt user change password before expiration" days c# active directory properties? refer screenshot http://i.stack.imgur.com/96ugm.png group policy applies registry settings computer or user. in case: passwordexpirywarning in hklm\software\microsoft\windows nt\currentversion\winlogon https://technet.microsoft.com/en-us/library/cc957396.aspx you can read using: int expiry = (int)microsoft.win32.registry.localmachine .opensubkey(@"software\microsoft\windows nt\currentversion\winlogon") .getvalue("passwordexpirywarning");

c++ - Changing data in Qt table view -

i went through previous questions on stackoverflow regarding updating table view , qt tutorial still cannot code work. want update table view data setdata method when push button pressed. method insertdata inside custom model tablemodel gets called data not changed (new rows added). problem? i'm not sure if relevant table view on qwidget on tab widget. mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include "tablemodel.h" #include <iostream> mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); this->datafetcher = new datafetcher(); tm = new tablemodel(0); ui->tableview->setmodel(tm); ui->tableview->show(); this->setpushbuttonhandlers(); } mainwindow::~mainwindow() { delete ui; delete this->datafetcher; } void mainwindow::setpushbuttonhandlers() { connect(this->ui->refreshdatabutton, sign...

wpf - How to auto-close a telerik RadDateTimePicker on selected date -

the control declared follows : <telerik:raddatetimepicker inputmode="datetimepicker" istabstop="false" height="36" focusable="false" validation.errortemplate="{x:null}" selectiononfocus="selectall" x:name="outwardstartdate" borderthickness="2,2,2,2" selectedvalue="{binding outwarddeparturedate, mode=twoway, validatesondataerrors=true, notifyonvalidationerror=true}" > i've failed find xaml attributes in order auto-close control when date selected. i've stumble upon this post on official website , question dated 5 years ago , none of current answers solved issue. you can hook sele...

algorithm - complexity analysis of kth smallest element in min heap -

i working on find k th smallest element in min heap. have got code complexity o(k log k) . tried improve o(k) . below code. struct heap{ int *array; int count; int capacity; }; int kthsmallestelement(struct heap *h,int i,int k){ if(i<0||i>=h->count) return int_min; if(k==1) return h->array[i]; k--; int j=2*i+1; int m=2*i+2; if(h->array[j] < h->array[m]) { int x=kthsmallestelement(h,j,k); if(x==int_min) return kthsmallestelement(h,m,k); return x; } else { int x=kthsmallestelement(h,m,k); if(x==int_min) return kthsmallestelement(h,j,k); return x; } } my code traversing k elements in heap , complexity o(k) . correct? your code, , in fact, entire approach - wrong, iiuc. in classic min-heap, thing know each path root children non-decreasing. there no othe...

java - Creating Spring-backed actors as routees -

problem: have thread pool allocated number of actors making blocking calls (eg. web service, database, etc). i have following configuration: threadpool-dispatcher { type = dispatcher executor = "thread-pool-executor" thread-pool-executor { core-pool-size-min = 4 core-pool-size-max = 8 } } and following setup method router actor: private final int numberofchildren = 4; @override public void prestart() throws exception { log.info("starting up.. creating {} children", numberofchildren); list<routee> routees = new arraylist<>(); (int = 0; < numberofchildren; i++) { actorref actor = getcontext().actorof(springactorextension.props(routeeclass) .withdispatcher(threadpool_dispatcher)); getcontext().watch(actor); routees.add(new actorrefroutee(actor)); } router = new router(new smallestmailboxroutinglogic(), routees); super.prestart(); } springactore...

ios - NSURLSession : getting null resumedata when downloading is running and in between that internet connection will change as ON to OFF mode -

i using nsurlsession downloading zip file server. following task working perfectly pause , resume downloading get progress of downloading get notification of when internet active or not active but there major problem while downloading going on @ time if internet connection gone time notification there can stored nsdata again assign when internet connection come. in internet connective method null data from [downloadtask cancelbyproducingresumedata:^(nsdata * resumedata){ nslog(@"resume data %@",resumedata); // getting **"null"** } please help!

c# - Radiobutton controls not sent to viewmodel -

i have view users choose value radiobuttons. problem once user clicks submit, values in view model (in controller) null. view model follows: public class preconditionsviewmodel { public list<keyvaluepair<int, string>> provinces { get; set; } [datatype(datatype.date)] [displayformat(dataformatstring = "{0:dd/mm/yy}", applyformatineditmode = true)] public datetime seedingdate { get; set; } [datatype(datatype.date)] [displayformat(dataformatstring = "{0:dd/mm/yy}", applyformatineditmode = true)] public datetime harvestdate { get; set; } public int drymatterpercentage { get; set; } public int postalcode { get; set; } } the action method: (for simplicity, have left method returning index. should able see model holds) [httppost] public actionresult save(preconditionsviewmodel model) { return view("index"); } the view: @using (html.beginform("save", ...

javascript - What does agent.maxSockets really mean? -

the official doc on agent.maxsockets says indicates limit on how many concurrent sockets http(s) server can have. did tests http.globalagent.maxsockets set 5 , expected can have 5 open websockets. turns out can have more 50 open websockets. can explain agent.maxsockets mean? http.agent instances used outbound http clients (e.g. via http.request() ), not inbound clients http.server . if use http.agent maxsockets set 5 http.request() , there @ 5 connected sockets particular server @ given time.

Not able to pass variable from one function to another in Javascript -

new javascript , html. in nutshell, attempting update score if user enters correct sum of random math problem. not able pass answer of problem function checks if user entered correct. want score increase one. reason function passing parameter "score" not being recognized it. here quick example of code. more concerned logic instead of looks right of program. know right score not update correctly problem lies in passing of "answer" variable. work through score increase once function @ least gets called. thank time! <html> <title></title> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body onload = "displayproblem()"> <script> function displayproblem(){ var answer = (firstnum) + (secondnum); var firstnum = (math.floor(math.random()*10) + 1); var secondnum = (math.floor(math.random()*10) + 1); document.getelementbyid("qstns"...

How to set Accelerator (keyboard shortcut) for Button in javafx -

how set on mnemonic parsing in same letter.in project set mnemonic in button, button settext change in every event action,but mnemonic same in _o short keys working 1 event.how solve problem import javafx.application.application; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.layout.stackpane; import javafx.stage.stage; /** * * @author user */ public class javafxapplication4 extends application { boolean b = false; @override public void start(stage primarystage) { button btn = new button(); btn.settext("hell_o"); btn.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent event) { b = !b; if(!b){ btn.settext("hell_o"); system.out.println("hello"); } else { btn.settext("w_orld"); ...

javascript - How to test a script in multiple sites just by using chrome dev-tools? -

Image
first of i'm not quite sure place kind of question, if not please tell me , i'll remove it. i'm developing script modifies dom bit , i'd test in real sites see if behaves correctly , detect issues. i wondering how simulate script @ page , if possible using chrome dev-tools. at first tried adding script script doesn't execute. i tried writing on console didn't work: var script1 = document.createelement("script"); var script2 = document.createelement("script"); var head = document.queryselector("head"); var text = 'myscript();'; script2[(script2.innertext===undefined?"textcontent":"innertext")] = text; script1.setattribute("src", "http://mysite.myscript.js"); head.appendchild(script1); script1.onload = function(){ head.appendchild(script2) }; edit: script worked in inside listening domcontentload event, of course when executed console, dom loaded. this can done...

ios - Objective-C add more UIButton horizontally -

Image
i using open source uialertview .view i want add more button horizontally, 1 in left side , in right of bye button, 1 my using source-code bellow -(void)popupview{ uiview* contentview = [[uiview alloc] init]; contentview.translatesautoresizingmaskintoconstraints = no; contentview.backgroundcolor = [uicolor klclightgreencolor]; contentview.layer.cornerradius = 12.0; uilabel* dismisslabel = [[uilabel alloc] init]; dismisslabel.translatesautoresizingmaskintoconstraints = no; dismisslabel.backgroundcolor = [uicolor clearcolor]; dismisslabel.textcolor = [uicolor whitecolor]; dismisslabel.font = [uifont boldsystemfontofsize:32.0]; dismisslabel.text = @"hi."; uibutton* dismissbutton = [uibutton buttonwithtype:uibuttontypecustom]; dismissbutton.translatesautoresizingmaskintoconstraints = no; dismissbutton.contentedgeinsets = uiedgeinsetsmake(10, 20, 10, 20); dismissbutton.backgroundcolor = [uicolor klcgreencolo...

angularjs - Awaiting for services to return data or converting service into global dataset and passing it into angular controller? -

i have simple problem of needing wait on data return service calls before executing logic depends on data in question. as confusing sounds have extract controller working on @ moment exhibiting problem. // async services: $stateparams, gettags, getstrands, getlessons, getplan, updateplan, saveplan myapp.controller('editnewctrl', ['$scope', '$stateparams', 'gettags', 'getstrands', 'getlessons', 'getplan', 'updateplan', 'saveplan', function ($scope, $stateparams, gettags, getstrands, getlessons, getplan, updateplan, saveplan) { // $stateparams correspondent 2 different routes controller // #/~/ // #/~/:planid // #/~/:planid/:year/:level $scope.planid = $stateparams.planid; // defined when editing plan $scope.year = $stateparams.year; // may or may not defined $scope.level = $stateparams.level; // may or may not defined ... // calls retrieve stuff server gettags.get({ ...

Wordpress empty search results -

i have created search page works fine. but have problem: when empty search, displays posts , pages, not of them. how can solve it? try : (in function.php ) function filter_search($query) { if ($query->is_search) { $query->set('post_type', array('post', 'your_post_type')); }; return $query; }; add_filter('pre_get_posts', 'filter_search');

c# - Parse to "American format" on my DateTime to work with a stored procedures in SQL? -

i have stored procedure takes 2 parameters. one int , datetime has formatted this: yyyy-mm-dd hh:mm:ss , parsing in c# gives me format: dd-mm-yyyy hh:mm:ss . european format. how can parse starting year, shown above. i need datetime , not string, stored procedure won't allow string. try following example datetime dt = datetime.now; string formatteddate = dt.tostring("yyyy-mm-dd hh:mm:ss");

xslt 1.0 - How padding char using xsl -

i want padding data space(any char) using xsl version 1.0. name field max chars length 10 (length must dyanamic) chars. need transfer data using xsl. in xml: <emp> <name>test</name> </emp> expected output : <emp> <name>test******</name> </emp> please let me know if have solution. in advance. try: substring(concat($yourstring, '**********'), 1, 10) example using input: xslt 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="name"> ...

mysql - Sorting the Data based on same set of columns -

i have 2 columns named country , country1 in same table having same datatype , data stored same i.e., india , united_states, country has 40 rows of data combination of india , united_states , country1 has 60 rows. need sort data based on india , united_states separately. can any1 me in this? when trying sort data either country1 gets sorted or country gets sorted not both using mysql. #name# #country# #country1# india united states b united states united states c india united states d india india e india i need dis name# #country# #country1 a india c india d india india e india try this: select * your_table country = 'india' , country1 = india order country desc, country1 desc

how remove invalid token in R.java in android -

public static final int 61=0x7f020004; i m creating 1 xml file after few time xml removed layout file id of xml in r.java file , displays error invalid token in id r.java file.i clean , restart eclipse r.java file still display error. can please me. you should build clean project, eclipse delete old references.

android - Elevation for FAB doesn't work -

i'm trying test fab android.support.design.widget.floatingactionbutton when set elevation xml layout, shadow shows elevation. when try change elevation programmatically: fab.setelevation(9); i error saying api should raised 14 21. what doing wrong? this used imagebuton, not fabbutton, simulates fab: can create fab-btn.xml in drawable folder simulate shadow: <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="false"> <layer-list> <item android:bottom="0dp" android:left="2dp" android:right="2dp" android:top="2dp"> <shape android:shape="oval"> <solid android:color="#44000000" /> </shape> </item> <item android:bottom="2dp" android:left="2dp" android:right="2dp" android:top="2dp...

flex - Save file opened with navigateToURL -

i'm using navigatetourl open pdf file generated jasper , it's working well. asked send email pdf file attachment. using velocity send emails in our application but, send attachments, have have file saved somewhere , have info of path , filename. possible save file opened navigatetourl? i'm using flex sdk 4.9.1. thank you. are using jasperexportmanager.exportreporttopdfstream() method show pdf? if so, try use jasperexportmanager.exportreporttopdffile(). can save pdf @ server. jasperprint jasperprint = jasperfillmanager.fillreport(jasper, parammap, con); // streaming pdf now? response.setcontenttype("application/pdf"); jasperexportmanager.exportreporttopdfstream(jasperprint, response.getoutputstream()); // save pdf somewhere. jasperexportmanager.exportreporttopdffile(jasperprint, path);

python - Filling an array with missing contigous numbers and getting the index -

having list (no repeated values): [67000, 67002, 67003, 67004, 67005, 67006, 67009] i want fill list contigous numbers missing on it, desired output be: [67000, 67001, 67002, 67003, 67004, 67005, 67006, 67007, 67008, 67009] and index of items have been added list: indx_list = [1,7,8] this try: lista_num = [67000, 67002, 67003, 67004, 67005, 67006, 67009] in xrange(len(lista_num)-1): if lista_num[i] != lista_num[i+1]-1: print lista_num[i] lista_n = lista_num[i] lista_nu = lista_num[i+1] while lista_n < lista_nu-1: lista_n = lista_n + 1 lista_num.insert(i+1, lista_n) else: print "ok" but i'm getting following output, not desired output. think i'm messing indexes. [67000, 67001, 67002, 67003, 67004, 67005, 67006, 67009] i haven't tried part of getting index of items first step of getting contigous number list not working. how can fix code , archieve goal? in advance....

python - Check if PrimaryKey exists with ponyorm -

i trying use pony orm see if primary key exists. got far, throws error. class favorite(db.entity): game = required(game) user = required(user) date_favorited = required(datetime) primarykey(user, game) here function if favorite.get(lambda: user, game) not none: favorited = 1 here errro typeerror: second positional arguments should globals dictionary. got: game[12] was helped out in github repo if favorite.exists(user=x, game=y): favorited = 1

r - Is there a simpler way to translate numbers into strings? -

a vector in r > <- c(1, 2, 3, 3, 2, 3, 1, 2, 1) that want "translate" (temporary) vector of strings 1 becomes "foo" , 2 becomes "bar" , 3 becomes "baz" . i can achieve sapply : > sapply(a, function(x) {if (x==1) return ('foo'); if (x==2) return ('bar'); return ('baz')}) [1] "foo" "bar" "baz" "baz" "bar" "baz" "foo" "bar" "foo" however, think there should alternative way without (what perceive misusing) sapply . case? just try: c("foo","bar","baz")[a] #[1] "foo" "bar" "baz" "baz" "bar" "baz" "foo" "bar" "foo"

vba - Regex to insert new line character after semicolon and remove names before email -

i have list of emails on 1 line clean up. in following format: jones, peter <jones.h7@petstore.com>; bradley, charles <bradley19@petstore.com>; frank, hilda <frank.hl@petstore.com>; and desired result follows: jones.h7@petstore.com; bradley19@petstore.com; frank.hl@petstore.com; so names , angle brackets around email removed. i regex solution. have tried replacing ;\s \r\n did not tthe expected result. new regex i'm stuck. instead of replacing <...> -ed emails, can match mails 1 of following regular expressions (if insist on regex solution): <([^@<>]+@[^@<>]+)>; the email addresses in captured group 1. see demo if need string replacing not need, may still use <([^@<>]+@[^@<>]+)>(;)|[^<>]+|<|> with $1$2 replacement string. see demo

php - Count times same value is in array -

this question has answer here: check how many times specific value in array php 6 answers i have question, if have following array: array ( [0] => apple [1] => apple [3] => banana [4] => apple ) is there way count how many times same value occurs in array? so in example how many times apple occurs in array. thanks in advance!! you can use php array_count_values() function. array_count_values($your_array); <?php $array = array("apple", "apple", "banana", "apple"); print_r(array_count_values($array)); ?> //output array ( [apple] => 3 [banana] => 1 )

c# - DataAdapter.Update() performance -

i have relatively routine looks @ database entries media files, calculates width, height , filesize, , writes them database. the database sqlite, using system.data.sqlite library, processing ~4000 rows. load rows ado table, update rows/columns new values, run adapter.update(table); on it. loading dataset db tables half second or so, updating rows image width/height , getting file length fileinfo took maybe 30 seconds. fine. the adapter.update(table); command took somewhere in vicinity of 5 7 minutes run. that seems awfully excessive. id pk integer , - according sqlite's docs, inherently indexed, yet can't think if run separate update command each individual update, have completed faster. i had considered ado/adapters relatively low level (as opposed orms anyway), , terrible performance surprised me. can shed light on why take 5-7 minutes update batch of ~4000 records against locally placed sqlite database? as possible aside, there way "peek into" ...

vba - Export entire table content to existing Excel workbook -

i have unsuccessfully searched on web , feel bit desperate least. here problem : i'm storing data in access database, , want extracting of data through access user form, existing excel workbook, using vba how ? figured simple way perform create intermediary table. code has determinate conditions user chose in form copy corresponding data initial table intermediary statement made said conditions send content of filled table in copy of pre-made excel workbook. i struggle sending. said workbook made can work data. can either create worksheet in workbook or directly put data in existing 1 - absolutely need choose name ! (let's it's gonna named "wsdata") so yeah, sending table content access excel, using access's vba code . if have idea of how performed, gratefully hear ! thank in advance, françois

javascript - Append <script> into <div> using jquery -

i'm trying append <script> tag <div> . whenever try this, script doesn't loads. works if hard coded under tag. but if try append <img> tag, works! here's partial code give ideas. $(document).ready(function() { var tag = '<script src="xxx.js"></script>'; // file grab images var tag2 = '<img src="some image link"></img>'; $('#test').append(tag); //testing $('#test2').append(tag2); //testing }); on html <div id="test"></div> <!-- not working! --> <div id="test2"></div> <!-- works! --> <div id="test"><script src="xxx.js file grab images"></script></div> <!-- works too! --> edit more info below: i've looked solutions on net , of answer same ones given here. in case, different others. that's because tag variable must database. <? $re...