Posts

Showing posts from February, 2015

python - ImportError: DLL load failed when importing Numpy installed in conda virtual environment -

in windows, created conda virtual environment command conda create -n test python=2.7 pandas scipy matplotlib numpy once created, activated virtual environment , went python interpreter. when trying import numpy, following error: >>> import numpy traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\anaconda3\envs\test\lib\site-packages\numpy\__init__.py", line 180, in <module> . import add_newdocs file "c:\anaconda3\envs\test\lib\site-packages\numpy\add_newdocs.py", line 13, in <module> numpy.lib import add_newdoc file "c:\anaconda3\envs\test\lib\site-packages\numpy\lib\__init__.py", line 8, in <module> .type_check import * file "c:\anaconda3\envs\test\lib\site-packages\numpy\lib\type_check.py", line 11, in <module> import numpy.core.numeric _nx file "c:\anaconda3\envs\test\lib\site-packages\numpy\core\__init__.py", l

multithreading - GUI with c++. lagged when i use button -

am new in c++ gui, modifying code sent machine me, want make while loop when click button, tried thread , still stuck. void cdlgwriteepc::loop() { // } void cdlgwriteepc::onbnclickedok() { std::thread loadingthread(&cdlgwriteepc::loop, this); loadingthread.join(); } join blocks current thread until other thread done, that's no help. should start worker thread, return , worker thread should send kind of message when it's done. the function names in example code seem it's msvc++ mfc application we'll work that. simply put, windows gui applications event driven, each time event happens wm_message sent. framework receives these messages , calls appropriate functions handle it. can define our own messages , message handlers. way worker thread can send such messages framework , call our handler function. wm_app defined starting point private user messages, there won't conflict existing system messages. ( https://msdn.microso

apache - How do you run a Lucene fuzzy query only on the non-nummeric part of a string? -

i want run fuzzyquery on string may or may not contain numeric characters in it. want query not match on edits numeric characters. instance if fed in "123abc" want matches still contain "123" in beginning. expect matches "123abg" "123ab" "123cbc" not want "124abc".

jquery - Bootstrap modal when activated inside tab -

wanted see if me. have edit button sits inside table sits inside bootstrap tabs. when click edit link display modal window doesnt work. however, when move same edit link outside of tabs, works charm. think has way bootstrap utilizes jquery work tabs. i'm jquery beginner don't have enough knowledge figure out. any appreciated link invoke modal <li><a href="#" class="btn btn-xs btn-primary" class="edittodo" data-toggle="modal" data-target="#edittodomodal"><span class="glyphicon glyphicon-pencil"></span></a></li> modal code <div class="modal fade" id="edittodomodal" tabindex="-1" role="dialog" aria-labelledby="edittodomodal"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button typ

partials - First argument in form cannot contain nil or be empty, rails -

attempting use form_for, have been getting error "first argument in form cannot contain nil or empty." error highlited in first line: <%= form_for @item |f| %> #------error highlited here <%= f.label :task %> <%= f.text_field :name, placeholder: "what have do?" %> <% end %> partial: <%= form_for @item |f| %> <%= f.label :task %> <%= f.text_field :name, placeholder: "what have do?" %> <% end %> controller: ``` class itemscontroller < applicationcontroller def index @items = item.all end def new @item = item.new end def create @item = item.new @item.name = params[:item][:name] @item.user = current_user if @item.save flash[:notice] = "item added; go accomplish it!" else flash.now[:alert] = "uh oh, didn't save. try again." render :new end end def show @item = item.fi

matplotlib - Plotting bar graph with the range in the x- axis -Python -

suppose have data such following, want plot bar graph show each value of range separate bar in x-axis , count in yaxis. range count 0 0-2 172 1 02-05 82 2 05-10 117 3 10-15 164 4 15-20 141 5 20 , above 380 i tried following, plt.bar(a['range'], a['count'], color='blue') but getting following error, valueerror: invalid literal float(): 0-2 i tried converting string. still result same. can me in plotting here? thanks if @ documentation plt.bar , need specify first argument left edges of bars want, not labels. , specify xtick labels, need use plt.xticks function. this: plt.bar(range(len(a['count'])), a['count'], color='blue') plt.xticks(range(len(a['count'])), a['range'])

Web Audio Api biquadFilter in Android needs extra configuration? -

here says web audio api works in chrome android, , here have tested cm browser, chrome , cyanogenmod default android 5.1.1 browsers, , pass tests (specially biquadnode one). but when open this codepen eq (biquadnode), can hear music not eq working. does biquadnode works in android? special implementation needed? *code pen required post var context = new audiocontext(); var mediaelement = document.getelementbyid('player'); var sourcenode = context.createmediaelementsource(mediaelement); // eq properties // var gaindb = -40.0; var bandsplit = [360,3600]; var hband = context.createbiquadfilter(); hband.type = "lowshelf"; hband.frequency.value = bandsplit[0]; hband.gain.value = gaindb; var hinvert = context.creategain(); hinvert.gain.value = -1.0; var mband = context.creategain(); var lband = context.createbiquadfilter(); lband.type = "highshelf"; lband.frequency.value = bandsplit[1]; lband.gain.value = gaindb; var linvert = context.crea

python - Telegram webhooks POST requests have empty payload -

i'm trying register webhooks telegram bot using api call setwebhook . i got public https url ngrok local server passed setwebhook . whenever new message being sent bot, post request local server expected, however, request payload empty. any idea? code please. used curl on web server set webhook. cheers edit. used command on wev server. optional ssl/tls cert. curl -f "url= https://yourdomainname.com/mybot.php " -f "certificate=@/path/to/cert.pem" https://api.telegram.org/bot /setwebhook.php hope helps man!!

java - tomcat linux folder name case issue -

i have linux server. have 2 folders in root of server: tomcat2 tomcat2 please note case of first letter. each of tomcats has same application in webapps folder. in first case (tomcat2) prints 'hello 1', in second case (tomcat2) prints 'hello 2'. i run startup.sh in tomcat2/bin folder. see 'hello 2' in logs. why? know linux case sensitive, bug? use tomcat 6.0.14. fixed or it's not issue?

java - Chinese and Japanese languages are not correct in Jfree Chart -

i'm using jfree chart in application. internationalization works german,russian,french...but in chinese, japanese x , y axis texts looks square box. how solve problem? thanks. check link below, seems talking same problem: http://www.jfree.org/phpbb2/viewtopic.php?f=3&t=109313 you need ensure using font supports characters trying display. if see squares, that's indication font doesn't have glyphs unicode character trying show.

python - How to recursively read all characters in a list? -

i need write function recursively read chars in file , append list.the function needs 2 parameters , file , list. recursion stumping me.any tips on thinking recursively appreciate well. bellow code have written print chars of list , without recursion. def newchar(usrfile,usrlist): line in usrfile: c in line: usrlist.append(c) print(usrlist) def main(): usrfile = open("input.txt",'r') usrlist = [] newchar(usrfile,usrlist) main() result : ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', ' ', 'p', 'r', 'i', 'n', 't', ' ', 'a', 'l', 'l', ' ', 't', 'h', 'e', 's', 'e', ' ', 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', &#

html - How can I get an absolute element to float right within its parent? -

so, i'm trying dropdown work part of menu. have ul few li elements added on left , want have li element float right. doing using relative position before, want able overflow , display on below it. i found question: css: overflow auto , z-index , found out have use absolute position sort of overflow happen. so, how this? this basic code structure: <ul> <li id="right_item1"/> (relatively positioned) ... <li id="absolute_position"/> (absolutely positioned, floating right) </ul> this should work you. ul{ position:relative; // need } #absolute_position{ position:absolute; right:0; bottom:0; }

Does MATLAB java.util have non-hash map/set? -

java.util.map/set abstract. have java.util.hashmap/hashset/hashtable . have map/set sorted keys in java.util ? sure, treeset , treemap . documentation part of java. e.g., can start here: https://docs.oracle.com/javase/7/docs/api/java/util/treeset.html some examples: >> x = java.util.treeset; >> x.add(2); >> x.add(1); >> x.add(3); >> x x = [1.0, 2.0, 3.0] >> y = java.util.treemap; >> y.put(10, 'ten'); >> y.put(20, 'twenty'); >> y.put(1, 'one'); >> y y = {1.0=one, 10.0=ten, 20.0=twenty} to see list of available java classes, it's easiest use javadocs web site, https://docs.oracle.com/javase/7/docs/api/ as noted in comments, calling java classes matlab not particularly fast. believe matlab uses java reflection construct allow execution of ad hoc, uncompiled java code ... not fast. still useful.

WSO2 DSS: Issue in Creating Data services using an oracle Stored Procedure with Ref Cursor and other Scalar out parameter -

i learning wso2 dss. trying implement 1 of use case using dss , oracle stored procedure. oracle stored procedure using has 1 input parameter , 2 scalar out parameter while 1 ref cursor. database script create table dss_dept ( dept_id varchar2(10), dept_name varchar2(10) ); create table dss_emp ( emp_id varchar2(10), fname varchar2(10), lname varchar2(10), title varchar2(10) ); create table dss_emp_dept ( dept_id varchar2(10), emp_id varchar2(10) ); create or replace procedure get_emp_data( p_emp_id in dss_emp.emp_id%type, p_emp_fname out dss_emp.fname%type, p_emp_lname out dss_emp.lname%type, p_dep_rset out sys_refcursor ) begin select fname, lname p_emp_fname , p_emp_lname dss_emp emp_id = p_emp_id; open p_dep_rset select dept_id dss_emp_dept emp_id = p_emp_id; end; / data insert script insert dss_dept (de

reactjs - React. Is it bad if presentational components contain container components? -

according https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0#.i63w9pvzw presentational components: may contain both presentational , container components** inside, , have dom markup , styles of own. have no dependencies on rest of app, such flux actions or stores. i think if presentational components contain container components, depend on flux or redux (or whatever container components depend on). that make presentational components hard test , reuse. it's not bad, it's fine. whole point of react-redux let connect container components directly store without having pass entire store down every component prop. component reuse isn't issue, since <provider> component make connected container components work anywhere below it. it's not hard test container components either. can make connected component default export, export unconnected component named export, can use tests, , manually pass props in tests.

Java params cannot be Resolved Eclipse -

for following block of code getting errors say: import com.agile.api.*; import java.util.*; public class addbom { public static final string username = "blahblah"; public static final string password = "1234"; public static final string url = "http://www"; public static iagilesession session = null; public static agilesessionfactory factory; public static final string parent = "p1"; public static final string child1 = "p2"; public static final string child2 = "p3"; public static void main(string[] args) { try { // create iagilesession instance session = connect(session); // create 3 parts iitem itemparent = createitem(parent); iitem itemchild1 = createitem(child1); iitem itemchild2 = createitem(c

Amazon S3 hardcode my bucket URL -

i using amazon s3 store images web app , ios app. i wonder if can safely hardcode bucket url when fetching images? don't have make 1 more api call fetch url. for example, hardcoding in apps code: https://s3.eu-central-1.amazonaws.com/mybucket/images/{some_var} just add - can in 2 ways virtual-hosted–style url (bucket name part of domain name in url) http://bucket-name.s3.amazonaws.com/<file-name> http://bucket-name.s3-aws-region.amazonaws.com/<file-name> path-style url (bucket name not part of domain , endpoint use must match region in bucket resides[except n. virginia]) http://region-name.amazonaws.com/bucket-name/<file-name> detail read: http://docs.aws.amazon.com/amazons3/latest/dev/usingbucket.html

php - Obtaining name of "father" array from "child" -

i want able name "father" array it's child, goal of writing http variables sent page, , written debug file. assuming have code (and page called remotely): $father = array ( getallheaders(), $_post, $_get ); $info = ''; foreach ( $father $child ){ $info .= ${"child"} . "\n"; $info .= '--------------' . "\n"; foreach ( $child $key => $val ){ $info .= $key . ' : ' . $val . "\n"; } $info .= "\n\n"; } //write $info debug file what i'm hoping achieve debug file containing following information: getallheaders() -------------- host : 1.2.3.4 connection : keep-alive // other members of getallheaders() array $_post -------------- // assuming page called via http post input1 : input 1 text input2 : input 2 text // other members of $_post array $_get -------------- // assuming page called via http input10 : input ten text input11 : input eleven text // other members of $_get ar

monitoring - Nagios Herald won't send emails -

i'm trying set nagios herald on production nagios instance. i've made setup neccessary , when run following dry run, notification sent straight away: root@mon1 objects]# /usr/local/nagios-herald/bin/nagios-herald --env-file /tmp/test_herald.out --message-type email -r my.email@address.net --formatter=$_servicemessage_formatter_name$ --nagios-cgi-url= http://192.168.0.1/nagios/cgi-bin/cmd.cgi --reply-to=nagios@somehost.com i want able test keeping legacy notifications in place, created new command, contactgroup, , contact definition: define command { command_name herald-service-email command_line /usr/local/nagios-herald/bin/nagios-herald --message-type email -r my.email@address.net --formatter=$_servicemessage_formatter_name$ --nagios-cgi-url=http://192.168.0.1/nagios/cgi-bin/cmd.cgi --reply-to=nagios@somehost.com } # nagios herald testing define contactgroup { contactgroup_name nagios-herald alias

swift - lock and unlock dispatch_queue_t in async task -

i want lock lockqueue2 complete process , when unlock lockqueue2 show "number :" number in dispatch_after . i need output : number set value 1 number 1 number set value 2 number 2 number set value 3 number 3 let lockqueue = dispatch_queue_create("lockqueue", nil) func test(num :int){ var number = 0 let lockqueue2 = dispatch_queue_create("lockqueue2", nil) dispatch_async(lockqueue){ lockqueue2.lock() // process or waiting sleep(2) dispatch_sync(lockqueue2) { number = num print("number set value ", number) lockqueue2.unlock() } } dispatch_async(dispatch_get_global_queue(qos_class_background, 0)){ // process or waiting sleep(3) dispatch_after(lockqueue2) { print("number :", number)//*** show number set in last dispatch *** } } } test(1) test(2) test(3) if you're dealing s

javascript - Import a variable from one page to another in PHP -

im making autocomplete search box lists different courses, , im trying use search button next display results of selected course on page using sql database. page looks this: index.php so whatever choice pick autocomplete, want "search courses" button link page , display results of selected course in search box page before. these results pulled sql database. im having trouble linking , can't figure out. this search box , button: <div class="row"> <div class="ui-widget col-md-4 col-md-offset-4"> <label for="tags">search: </label> <input id="tags" type="search"> <input type="submit" value="search courses"> </div> </div> do need set sort of variable pass on next page? appreciate help, thanks. this autocomplete.php file: <?php $mysqli = new mysqli("localhost", "scott", "tiger", "cours

javascript - Uncaught TypeError: Cannot read property 'total' of undefined -

i json response object do: var json = json.parse(res.text); i print json , json back. when retrieve value inside json.body.value.total gives error: uncaught typeerror: cannot read property 'total' of undefined i have no idea why. pasted value receive var json , printed on console , able retrieve total. cannot through code. there json value total. unable recognize. on console, works not work in code. i json response object retrieve using response.text . think needs change in parsable object returns undefined it('returns http 200', function (done) { chai .request(baseurl) .get('/api/') .set('authorization', 'basic abc') .query({val:'hey'}) .end(function(err, res) { expect(res).to.have.status(200); var json = res.text; console.log('val: '+ json.parse(json.body)); var val = json.body.value.total; //undefined e

jquery - How can I determine the cause of the Internal Server Error resulting from my Ajax call? -

Image
in asp.net mvc app, ajax call: $.ajax({ type: 'get', url: '@url.action("getunitreportpairvals", "home")', data: { unit: unitval, report: rptval }, // data: model, contenttype: 'application/json', cache: false, success: function (result) { alert(result); }, error: function (result) { alert('failed'); alert(result); } }); ...calling controller method: public jsonresult getunitreportpairvals(string unit, string report) { int rptid = getreportidforname(report); datatable unitreportpairemailvalsdt = new datatable(); string qry = string.format(sql.unitreportpairemailquery, unit, rptid); unitreportpairemailvalsdt = sql.executesqlreturndatatable( qry, commandtype.text, null ); var model = unitreportpairemailvalsdt; return json(model); } i see "failed" alert, , "result" object has no end of data

c++ - derived class giving error when accessing private variables of base class -

i making c++ program store employee's data name, id, saleamount, commission amount , calculate earning (sales*commission). using concept of inheritance. base class 'employee' , derived class 'senioremployee'. when run program, compiler gives me error cannot access private members of base class. errors error: 'std::__cxx11::string employee::name' private. another error on 2nd line error: 'int employee::id' private again same error on 3rd line error: 'double employee::sales' private following code. have included files. file employee.h #ifndef employee_h_ #define employee_h_ #include <iostream> #include <string> using namespace std; class employee { public: employee(string empname, int empid, double empsales, double empcomm); void setname(string empname); string getname(); void setid(int empid); int getid(); void setsales(double empsales); double getsales(); vo

hashmap - Printing a java map Map<String, Object> - How? -

this question has answer here: how efficiently iterate on each entry in map? 35 answers how print information map has object value? i have created following map: map<string, object> objectset = new hashmap<>(); the object has own class own instance variables i have populated above map data. i have created printmap method, can seem print keys of map how map print <object> values using each loop? so far, i've got: for (string keys : objectset.keyset()) { system.out.println(keys); } the above prints out keys. want able print out object variables too. i'm sure there's nice library sort of thing you... stick approach you're going with, map#entryset gives combined object key and value . like: for (map.entry<string, object> entry : map.entryset()) { system.out.println(entry.getkey() + "

Is it possible for the Braintree Drop-In UI PayPal button pop-up to work on a webpage that is displayed inside an Adobe AIR desktop app? -

we have web page uses braintree drop-in ui. if visit page in normal browser chrome, pop-up paypal button works properly. but want use page inside our adobe air desktop app. when view page in air fine except paypal button pop-up doesn't appear on click, paypal disabled. why doesn't pop-up work? trying find code pop-up think buried somewhere in here: https://js.braintreegateway.com/v2/braintree.js full disclosure: work braintree. braintree.js not supported in compile-to-native runtimes. i'd suggest investigating adobe air documentation determine how handles pop-ups.

python - Pygame. TypeError: 'pygame.Surface' object is not callable -

i new python, pygame, , coding in general. i not know why code getting: "typeerror: 'pygame.surface' object not callable" and black screen. here code: import pygame ptypeerror: 'pygame.surface' object not callableygame.init black = (0,0,0) white = (255,255,255) red = (255,0,0) green = (0,255,0) blue = (0,0,255) char_sprite = pygame.image.load("man.png") display_height = 800 display_width = 1000 dead = false framerate = 60 game_display = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption("tiny fighter") clock = pygame.time.clock() def char(x,y): game_dispaly.blit(char_sprite,(x,y)) x= display_width / 2 y= display_height / 2 while not dead: event in pygame.event.get(): if event.type == pygame.quit: dead = true game_display.fill(green) char_sprite(x,y) pygame.display.update() clock.tick(framerate) pygame.quit() quit() full traceback:

performance - Parallel processing of files in java with ExecutorService does not use all of the CPU power -

i have directory contains 1000s of csv files need parse. have implemented executorservice class of java job, wherein assign each thread csv file parse. have 4 cores in machine. efficiency compared single-threaded application. however, when see cpu utilization( using task manager) doesn't seem utilising of cpu power, % of cpu used 30%-40%. wanted know if approach correct. file dir = new file(file); if(dir.isdirectory()){ file[] files = dir.listfiles(); for(file f : files){ string file_abs_path = f.getabsolutepath(); int index = file_abs_path.lastindexof("/") + 1; file_name = file_abs_path.substring(index); futureslist.add(eservice.submit(new myparser(file_abs_path))); } object gpdocs; for(future<list<myobj>> future:futureslist) { try { docs = future.get(); arraylist = (list<myobj>)docs; iterator<myobj> = arraylist.iterator(); while(it.hasnext()){ doc = createdocument(file_name,it.next()); try{

css - Unable to get rid of Firefox focus display in radios and checkboxes -

Image
i'm trying rid of blue focus outline in firefox. when set outline 0 or none, nothing happens. if set outline else, separate outline appears (in example square green one). tried using box shadow. if try remove or modify border, nothing happens. (i can't make separate border or remove automatic outline) in example tried using inline style !important. when run snippet in editor in firefox focus outline shows straight away. $(function(){ $('#test').focus(); }); [type=radio]:focus { box-shadow:1px 1px 4px red; outline:1px solid green; border:0 !important; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="radio" name="question-preview2" /> 1<br> <input id="test" type="radio" name="question-preview2" /> 2<br> <input style="border:none !important;" type="ra

javascript - gulp-concat twice the content -

that's weird thing me, have task concat .js files , uglify them watcher, concat task twice content in every call... here gulpfile: 'use strict'; let gulp = require('gulp'); let stylus = require('gulp-stylus'); let sourcemaps = require('gulp-sourcemaps'); let concat = require('gulp-concat'); let uglify = require('gulp-uglify'); let plumber = require('gulp-plumber'); let bootstrap = require('bootstrap-styl'); let rupture = require('rupture'); let copy = require('gulp-copy2'); /* prepare paths */ let base = './theme'; let themename = 'own-theme'; let paths = { stylus : `${base}/${themename}/css`, js : `${base}/${themename}/js`, vendor : `${base}/${themename}/js/vendor` } /* stylus compile */ gulp.task('stylus-compile', () => { return gulp.src([`${paths.stylus}/dev/*.styl`, `${paths.stylus}/!**/_*.styl`

Read comma separated properties with configuration2 in java -

i have property: move.patternfile.include = *1a.txt,*2a.txt and i'm trying put in list, using apache commons configuration2. the code have : configurations configs = new configurations(); abstractconfiguration config = configs.properties(new file(filename)); config.setlistdelimiterhandler(new defaultlistdelimiterhandler(',')); i can read others properties, 1 want still 1 size list. this command retrieve values : list<string> linclude = configuration.getlist(string.class, "patternfile.include"); can please? based on this appears delimiter has set before properties read file. code below works when run it, generates warning. parameters params = new parameters(); filebasedconfigurationbuilder<propertiesconfiguration> builder = new filebasedconfigurationbuilder<propertiesconfiguration>( propertiesconfiguration.class).configure(params.filebased() .setlistdelimiterhandler(new defaultlistdeli

java - Sorting an array of objects by two doubles -

so had delimited file read array. array[0] boxid (double) and array[1] movieid (double) i have no clue how i'd able sort array these 2 doubles. comments? i've tried looking @ other questions on website got confused them. i'm in first programming class. movies[] newmastermovies = new movies[200]; int newmastercount = 0; int mastercount = 0; int updatecount = 0; while (updatecount < updatetotalcounter || mastercount < mastertotalcounter) { string updatecompare = updatemovies[updatecount].getboxid() + updatemovies[updatecount].getmovieid(); string mastercompare = mastermovies[mastercount].getboxid() + mastermovies[mastercount].getmovieid(); int compare = updatecompare.compareto(mastercompare); if (compare > 0) { newmastermovies[newmastercount] = mastermovies[mastercount]; mastercount++; newmastercount++; } if (updatemovies[updatecount].getactioncode()

Selenium with phantomJS fails but is working in Firefox -

i want automate download of google takeout data using selenium phantomjs webdriver. developed actions in selenium ide firefox add-on , converted html output of test case js using npm package selenium-html-js-converter . selectors working in mozilla firefox 45.0.2 if use converted version fails following message: error: failure in selenium command "click("//tbody[@data-id=drive]/tr/td/div/", "")": [elementbyxpath("//tbody[@data-id=drive]/tr/td/div/")] error response status: 32, , invalidselector - argument invalid selector (e.g. xpath/css). this part want exclude google apps takeout. build selectors hand since don't want rely on classes , ids of elements since these automatically generated build tool , change @ time. i read in post quotes problem evaluation still fails without quotes. tried change user agent in firefox 1 phantomjs using ( mozilla/5.0 (unknown; linux x86_64) applewebkit/538.1 (khtml, gecko) phantomjs/2.1.1 safari/538

javascript - Optional ending capture group -

i'm trying have 3 total capture groups last optional. i'm running issue i'm not sure how exclude last delimiter last group , have end. here's pattern /(.+)\@(.+)\:(.+)/ here's example strings test@hello // => ['test', 'hello'] test@hello:optional // => ['test', 'hello', 'optional'] use string.split string.split(/[:@]/) [:@] matches colon or @ symbol split function splits string according matched chars. var s = 'test@hello:optiona' alert(s.split(/[@:]/)) or var s = 'test@hello:optiona' alert(s.match(/[^@:]+/g))

neo4j - How to classify the attributes according to the attribute -

i have entity class this: @nodeentity public class patent { @graphid private long patentid; private string patentname; //2016-02-01 private string authorizedtime; private string patentnumber; @fetch @relatedto(type = "authorizedperson") private set<researcher> authorizedpersons = new hashset<researcher>(); private string createtime; private string description; i want result this: year     total 2013      6 2014      7 i try use cypher query: match (n1:patent) collect( distinct substring(n1.authorizedtime,0,4)) coll,substring(n1.authorizedtime,0,4) val return coll, reduce(s=0, val in coll | s + 1) numbyy ; but no success. how classify attributes according attribute? thanks lot! this query should return each year , number of nodes year, ordered year: match (n1:patent) return left(n1.authorizedtime, 4) year, count(*) total order year;

javascript - Dropdown automatically selected a value -

i need problem. want make dynamically dropdown , when select value 1 dropdown "a", dropdown set "b". i have javascript function dynamically dropdown this. <script type="text/javascript"> function coba(){ document.getelementbyid("add").innerhtml += " <inputclass='department_name' type='text' size='50' />"; } </script> reference: how dynamically change item of 2 related combobox in short: in file1.php , retrieve mysql tbl1 , display in combo box a . on change of combo box a , fetch value of option , pass php file file2.php via ajax , display output in file1.php produced file2.php . in file2.php , retrieve mysql tbl2 id passed ajax , generate combo box b . example: index.php <script type="text/javascript"> function getxmlhttpobject() { if (window.xmlhttprequest) { return new xmlhttprequest(); } if (window.a

ruby - Rails - Active Record Search ".where" With Or Statement For Same Criteria -

in rails app, i'm trying let user search products using key word or key phrase matches products' descriptions , names. according documentation, have written so: def productsearch @results = 0 if !params[:searchinput].nil? @results = 1 @searchinput = params[:searchinput] @searchcriteria = "%#{params[:searchinput]}%" @productlist = product.where("description ? or name ?", @searchcriteria, @searchcriteria) end end what frustrates me line: @productlist = product.where("description ? or name ?", @searchcriteria, @searchcriteria) is there short-hand matching both description , name of product same search criteria? i'd mention i'm new ruby on rails , school project have build e-commerce website group, appreciated. try: @productlist = product.where("description :search or name :search", search: @searchcriteria)

algorithm - program to get all the combinations of ball-box application -

i new combination , permutation related algorithms. have thoughts on how program solve classical problem? there 3 boxes(a,b,c) , 10 balls(1,2,3,...,10), want put balls boxes. result should {box a: ball 1; box b: ball 2,3,4; box c: ball 5 6 7 8 9 10}, {box a: ball 1 2; box b: ball 3 4 5; box c: 7 8 9 10}, .... want combinations (not number of different combinations). furthermore, if there constraint each box contains @ 4 balls? thank you. you can put first ball in of 3 boxes, have 3 variants. there 3 variants second ball, 3 third , on. they independent, have 3^10 variants, , each variant has 1:1 mapping number in range 0..3^10-1. consider number in ternary number system, k-th ternary digit of number tells box (a=0,b=1,c=2) k-th ball belongs to. example 3 balls: number 14 = 112 ternary, first ball in c, second , third in b for case of limited box size simple approach recursive generation - arguments of recursion list of available balls , current combination (li

html - Click behavior changes on SVG when changing between<img> and <object> -

Image
i have 4 svg buttons part of main menu on personal webpage. /----------------------------------------------------------------------------------------------------------------------------------/ when 1 clicked, 4 buttons retract corners , respective section revealed (i.e. aboutme button --> aboutme section). originally had svg objects embedded in img tag so: <img class = "button active" id = "person-icon" src = "resources/main-page-icons/person-icon.svg"/> i did because read when there no need animate svg isn't necessary embed in object/embed tag. however, decided today wanted create hover effect svg element. had change img tag object allow styling/animating <object class = "button active" id = "person-icon" data = "resources/main-page-icons/person-icon.svg" type = "image/svg+xml"></object> the hover effect works expected, but can't click it . inspecting element reveals

php - How do I link to external images in my WP posts -

i scraping site , putting data in wp site. there lots of images in posts. i want when importing scraped data wp site, want link images site directly external url instead of downloading image server. i grammatically importing scraped data site. here part of adding image // image $ins_q = "insert wpxw_posts (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, " . "comment_status, ping_status," . "post_password, post_name, to_ping, pinged, post_modified,post_modified_gmt, post_content_filtered,post_parent," . "guid,menu_order,post_type," . "post_mime_type,comment_count) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $sth = $conn->prepare($ins_q); if (!$sth->execute(array( $post_author, $date, $date, "", sanitize_title_with_dashes($image_name), "", "inherit", "