Posts

Showing posts from June, 2011

php - How to Initiate Custom Redux Framework Config File -

i'm getting started php , i'm trying use redux framework build theme settings panel. i've installed plugin on local dev environment, running wp multi-site, , activated demo. now want copy sample-config.php file , build out own configuration. however, can't seem initialize copied file. the docs have copy sample config "a new location" , require file so: require_once (dirname(__file__) . '/sample/sample-config.php' so made copy , moved root directory of redux plugin so: /plugins/redux-framework/my-custom-config.php i'm not sure i'm supposed add require_once statement . i've read docs sort of glazed on this. tried adding functions.php file, doesn't work. require_once wp_plugin_dir . '/redux-framework/my-custom-config.php'; can please clarify should place copied sample-config.php file , should place require_once statement? lead dev @ redux here. support questions our issue tracker quite responsiv...

perl - Trouble with shift and dereference operator -

i have question regarding how left , right sides of -> operator evaluated. consider following code: #! /usr/bin/perl use strict; use warnings; use feature ':5.10'; $, = ': '; $" = ', '; $sub = sub { "@_" }; sub u { shift->(@_) } sub v { $s = shift; $s->(@_) } 'u', u($sub, 'foo', 'bar'); 'v', v($sub, 'foo', 'bar'); output: u: code(0x324718), foo, bar v: foo, bar i expect u , v behave identically don't. assumed perl evaluated things left right in these situations. code shift->another_method(@_) , shift->another_method(shift, 'stuff', @_) pretty common. why break if first argument happens code reference? on undefined / undocumented territory here? the operand evaluation order of ->() undocumented. happens evaluate arguments before lhs (lines 3-4 , 5 respectively below). >perl -mo=concise,u,-exec a.pl main::u: 1 <;> nextstate(main ...

ember.js - Ember auth transition.retry() after login doesn't transit while testing -

i having issues testing login , related features of app. app works perfectly, test fails. testing, use qunit karma i have created few authenticated routes(say accounts) 1 can visit after logging in. if user goes accounts route without logging, redirected login page , after successful login, redirected accounts page. app.authenticatedroute = ember.route.extend({ beforemodel: function(transition) { if (!app.authmanager.isauthenticated()) { this.redirecttologin(transition); } }, redirecttologin: function(transition) { var logincontroller; logincontroller = this.controllerfor('login'); logincontroller.set("attemptedtransition", transition); this.transitionto("login"); }, events: { error: function(reason, transition) { this.redirecttologin(transition); } } }); app.logincontroller = ember.objectcontroller.extend({ attemptedtransition: null, loginuser: function() { var attemptedtran, form_da...

php - Do I need to persist a prepared statement? -

i have following code: public function getdefinitions($wordid) { $query = $this->dbc->prepare('select * definitions wordid = ?'); $query->bind_param('i', $wordid); $query->execute(); // ... $query->close(); return $result; } it seem recreate prepared statement each invocation. not seem take advantage of full benefit of prepared statements. in case these prepare statements stored server side . true? if so, should store prepare statement (in case property) persist between invocations. there way persist prepared statement between requests? assume that's stored procedure? currently using mysqli. please note api difference if using driver (e.g. pdo). should store prepare statement (in case property) persist between invocations. i wouldn't "should". may, if foresee lot of consequent invocations (which cannot group call @ once). either way, scarcely able notice real life difference. i...

How do I keep the leading 0 from A1 using formula =left(A1,4)? -

how keep leading 0 a1 using formula =left(a1,4)? ex. have 01234567 in cell a1. want 1st 4 digits of number placed in cell d1 (including leading 0). so should 0123, not 1234. i've used =left(a1,3) , works, however; i'm working lot of data , changing 1 cell here , there pain. if know sure number of digits (including leading zeroes) fixed, should work (for fixed field width of 8): =left(text(a1,"00000000"),4) the number of zeroes in second arg text field width.

Accessing Imgur API with Python 3.4.1 and Urllib3 -

i trying wrap head around imgur api. have found examples of how send authorization header imgur, use urllib2, , apparently, using pyhton 3.4.1 can use urllib3. so have tried couple of things , none of them seem working. from this post tried using basic_auth header: http = urllib3.poolmanager() header = urllib3.make_headers(basic_auth="client-id" + client_id) r = http.request('get', 'https://api.imgur.com/3/gallery/r/pics', headers=header) that gives me 403 error. from this post tried method instead: http = urllib3.poolmanager() header= {"content-type": "text", "authorization": "client-id" + client_id} r = http.request('get', 'https://api.imgur.com/3/gallery/r/pics', headers=header) that returns 403. now have got step closer reading urllib3 documents , tried sending authorization field instead. http = urllib3.poolmanager() r = http.request('get', 'https://api.imgur.com/3...

precision - CGAL: Point on the line? -

i've encountered strange thing in cgal. have line , point supposed on line. code typedef cgal::exact_predicates_exact_constructions_kernel kernel; int main( ) { cgal::line_2<kernel> l(0.2, 1.0, -1.4); std::cout << l.has_on(cgal::point_2<kernel>(-3.0, 2.0)) << std::endl; std::cout << l.y_at_x(-3.0).exact() << std::endl; return 0; } produces output: 0 36028797018963967/18014398509481984 ok, maybe exact_predicates_exact_constructions_kernel not enough... (why?) i tried use kernel defined cgal::quotient instead: typedef cgal::quotient<cgal::mp_float> nt; typedef cgal::cartesian<nt> kernel; int main( ) { cgal::line_2<kernel> l(0.2, 1.0, -1.4); std::cout << l.has_on(cgal::point_2<kernel>(-3.0, 2.0)) << std::endl; std::cout << l.y_at_x(-3.0) << std::endl; return 0; } and result more mysterious me: 0 2/1 am missing or bug? when construct line 0.2, 2 con...

Overwrite variable to file in python -

i defined function generates names , run loop: output = open('/tmp/namegen-output.txt', 'w') while true: var = namegen(name) . . . if sth: output.write(var) elif other: output.write(var) break else: break output.close() update: first iteration ,content of namegen-output.txt : a b c second iteration: a b c d e and etc so if overwrite second iteration just: d e what going ask is: as see var equals namegen() , each iteration content of var written namegen-output.txt want overwrite output of each iteration of namegen() namegen-output.txt no appending it. could possibly me? thank you you can truncate existing file without opening , closing it, , flush ensure written to: output = open('/tmp/namegen-output.txt', 'w') while true: var = namegen() . . . if not sth , not other: break else: ...

c# - ASP.NET WebApi IExceptionLogger doesn't catch exceptions -

i'm trying setup global exception handler outlined here: web api global error handling . i"ve setup case exception gets thrown within controller constructor. exception isn't getting logged. instead webapi returning exception , full stack trace calling client json message. i don't know if matters, controllers actions using async / await this: [httpget, route("getlocationnames")] public async task<ienumerable<string>> get() { return await adapter.getlocationnames(); } i have following implementation: using log4net; using system.threading.tasks; using system.web.http.exceptionhandling; namespace warehouse.management.api { public class log4netexceptionlogger : exceptionlogger { private ilog log = logmanager.getlogger(typeof(log4netexceptionlogger)); public async override task logasync(exceptionloggercontext context, system.threading.cancellationtoken cancellationtoken) { log.error("an ...

c++ - Removing the last vertex from a boost graph throws an exception -

here's code i'm using: typedef boost::adjacency_list<boost::vecs, boost::vecs, boost::bidirectionals> graph; graph g; typedef graph_traits<graph>::vertex_descriptor vertex; typedef graph_traits<graph>::edge_descriptor edge_desc; typedef graph_traits<graph>::vertex_iterator vertex_iterator; vertex u, v; u = boost::add_vertex(g); v = boost::add_vertex(g); edge_desc edge; bool inserted = false; boost::tie(edge,inserted) = boost::add_edge(u,v,g); boost::remove_edge(edge,g); cout<<"\nafter removing edge"<<endl; cout<<"\nremove u"<<endl; boost::remove_vertex(u,g); cout<<"\nremove v"<<endl; boost::remove_vertex(v,g); cout<<"\n!everything removed"<<endl; in console see upto "remove v" , *.exe has stopped working window. removing last vertex threw exception. when catch exception , print it, says "bad allocation." in actual program (above hav...

Dynamic substrings of SET command in batch-file -

i want batch-file testing substrings of set command, %var:~5,3% see below: @echo off setlocal enabledelayedexpansion set var=abcdefghijklmnopqrstuvwxyz echo. echo string: abcdefghijklmnopqrstuvwxyz echo. echo samples of substrings: echo ~5,3 : %var:~5,3% echo.~5 : %var:~5% echo.~0,-2 : %var:~0,-2% echo. echo.test more: (type 000 exit command prompt) :loop set /p "substr=~" echo.!var:~%substr%! echo. if %substr%==000 exit goto:loop output input's user : ~5 fghijklmnopqrstuvwxyz and output input's user : ~5,2 var:~5,2 what solution? thnx. :loop set /p "substr=~" if "%substr%"=="000" exit echo(!var:~%substr%! echo( goto loop

wordpress plugin - Remove duplicate products with same sku in woocommerce -

i have used wp import http://wordpress.org/plugins/woocommerce-xml-csv-product-import/ import products xml file, has created duplicate products same sku. how can delete duplicates , leave recent one? maybe database query? or there woocommerce/wordpress option missing? thank you you can use allaerd 's delete produt sku. it can found here delete produtcs sku plugin description put’s products on status trash not in last csv. uses sku’s this. @ beginning of import, products marked. products imported / merged mark removed. products still have mark after rows processed, pur on status trash. hope works. luck!

actionscript 3 - AS3 BitmapData Threshold Bug -

the bitmapdata class has threshold method allows check how many pixels satisfy condition (e.g. "<=",">","=="); method not appear work when alpha channel in threshold in range (0,ff), although works on extremes 0 , ff. code used test: bd = new bitmapdata(16,16,true,0); var i:int = 0; var x:int, y:int; (var a:uint = 0x0; a<=0xff; a++){ x = math.floor(i/16); y = - x*16; // trace(x,y); var col:uint = combineargb(a,0xaa,0xbb,0xcc); trace('set: '+col.tostring(16)); bd.setpixel32(x,y,col); var getp:uint = bd.getpixel32(x,y); trace('get: '+getp.tostring(16)); trace('test threshold @ '+getp.tostring(16)+': '+bd.threshold(bd,bd.rect, new point(), "==", getp,getp)); i++; } so create 16x16 bitmap data , fill argb value such 1aaabbcc ffaabbcc. as3 not set colours same values requested, manipulated version of them. nevertheless, if set pixel, , use threshold method find...

html - CSS3 Animations, not quite getting it right -

you can see have tried do. want bottom of each image rollover appear after right pops , fades in. not when mouse hovered on bottom of each image. i'm having trouble making whole thing clickable blog post without overshadowing/stopping individual links, , short code selection being workable. i've been @ days no luck... (the social icons, individual links i've not done yet) anyone see i'm going wrong? i've got fiddle @ bottom. ideally i'd play on hover delay black box @ bottom. i'm close annoyingly annoying. html: <body> <div class="wrapper"> <div class="container left"> <img src="http://www.glennleader.co.uk/wp-content/uploads/2014/05/suit6.jpg" alt="image" /> <div class="sig"></div> <div class="innercontent css3-2"> <span class="css3-2 resize"...

confidence interval - Render bands / bandData in jqplot when series contains null values -

i using jqplot render line graph. my series data looks like: results =[ ['1/1/2014', 1000], ['2/1/2014', 2000], ['3/1/2014', 3000], ['4/1/2014', 4000], ['5/1/2014', null] ]; my call jqplot looks like $.jqplot('mychart', results, { series: [ { rendereroptions: { bands: { show: true, interval: '10%' }, } } ] }); the chart render, missing 10% bands above , below. if change null value ['5/1/2014', null] ['5/1/2014', 5000] bands render correctly. my data have missing values. there way make bands render non-null data points on line, if line does have null data points? instead of sending null values, omit them entirely , depend on dateaxisrenderer correctly space values on axis. results = [ ['1/1/2014', 1000], ['2/1/2014'...

java - Dynamically add items to list view using custom adapter for Android app -

so, right have custom adapter class takes in array of locations , adds them listview. fine , dandy, add locations listview after initialization. example, can "add location" , add listview. here main activity: package com.example.listviewtest; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.listview; public class mainactivity extends activity { private listview listview1; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); location location_data[] = new location[] { new location(r.drawable.ic_launcher, "location 1", "fruit!", "2 miles", "8-4 mon-fri\nclosed sun"), new location(r.drawable.ic_launcher, "location 2", "veggies!", "2 miles", "8-5"), new location(r.drawable.ic_launcher, "location 3", "p...

Jquery .click function with If Else Statement -

i trying create click event first displays loading icon plus or minus icon. code works on first click when click same icon again doesn't continue if else statement. here jquery code : $('a.addqueue').click(function(){ var plusicon = '<i class="fa fa-plus"></i>'; var minusicon = '<i class="fa fa-minus"></i>'; var loadingicon = '<i class="fa fa-circle-o-notch fa-spin"></i>'; var innericon = $(this).html(); $(this).html(loadingicon).delay(500).queue(function(){ if(innericon == plusicon) { $(this).html(minusicon); } else if (innericon == minusicon) { $(this).html(plusicon); } }); }); here html code: <ul class="list-unstyled"> <li>item 1: <span class="semi-bold">xxxx</span> <a class="addqueue" href="javascript:;"><i class="fa f...

iphone - Does the Apple Push Notification Service represent a privacy concern? -

i've been reading extensively on apns, , curious if familiar apple's stance on server-side logging. in order allow push notifications, each device (such iphone) "establishes accredited , encrypted ip connection service , receives notifications on persistent connection." source: https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/remotenotificationspg/chapters/applepushservice.html this means apple tracks every single ip address user's phone connected @ time including wifi hotspots, , initiate automatic connection servers when user enters his/her own home, when user not using his/her phone. while understand process essential allowing push based notifications, question how long apple keep log data? (they claim not log content of notifications including imessage here: http://images.apple.com/ipad/business/docs/ios_security_feb14.pdf however, i'm interested in logging of metadata associated notifications.)

Google File Picker loading wrong documents when signed into multiple accounts -

we have following scenario: user logs google drive account a then, user adds new account , logs google drive account b (two active valid accounts @ point) while in account b, user clicks create button in drive. our app requests user select account wants use file creation , user selects account b (same 1 using). our app shows file picker files gets see ones in account a, not in account b. we have followed steps indicated in developers api guide, including setting authorization token. here our createpicker function: function createpicker() { if (pickerapiloaded && oauthtoken) { new google.picker.pickerbuilder() .addview(google.picker.viewid.docs) .setselectablemimetypes(selectablemimes) **.setoauthtoken(oauthtoken)** .setcallback(pickercallback) .enablefeature(google.picker.feature.multiselect_enabled) .build() .setvisible(true); } } and how obtaining oauthtoken value: gapi.auth.authorize({ client_id: ...

asp.net - Enabling/Disabling RequiredFieldValidator -

i have 2 combo box drop downs. on page load 2nd drop down validator disabled. if user selects value first drop down enable it. 2nd drop down enables validator not. page load protected sub page_load(sender object, e eventargs) handles me.load combox_ger2.enabled = false valid_ger2.enabled = false end sub is fired combox_ger1.selectedindexchanged if combox_ger1.selectedindex = -1 else combox_ger2.enabled = true valid_ger2.enabled = true end if in every page_load add ajaxmanager.ajaxsettings.addajaxsetting(combox_ger1,combox_ger2) ajaxmanager.ajaxsettings.addajaxsetting(combox_ger1,valid_ger2) this should work.

jquery - Bootstrap Elements inactive in mobile -

i have bunch of elements on page visible breakpoint, when dimensions within tablet or mobile size want able display content modals. ok, have managed show buttons needed modal on smaller screens, expand screen, content has residual elements modal functionality, such fade , modal. plus when close modal element: display: none, problem, , if decrease again fade effect still there. is there anyway of enabling modal effect when within breakpoints? you need responsive utilities , utilise .visible-xs or .hidden-xs in class tags of modal. see here: http://getbootstrap.com/css/#responsive-utilities

mercurial - push a named branch to limited people only -

i , guy needs share named branch not supposed seen/pulled third party until ready. there way push branch between us? thanks there no easy built-in way can share changesets , still not accidentally push them central server. what would clone repository separate place , use synchronization point. let's you're using bitbucket, , want work on changes before making them available public. clone repository private repository, giving both access, , push , pull central repository hearts content. @ point you're ready, , push public central repository , delete private one. you set local clones can push , pull between you, not push central repository. here clone repository on local machines, , change .hg\hgrc file point friends repo, can both pull , push each other. @ point use hg push url-to-central-repo push central repo , share changesets. there use of phase system use, in case add hassle i'm not sure like. flag changesets secret, prohibit them being pushe...

jquery - Active link on a one page website -

i have 1 page website need active link in menu different colour. there way in code have when link clicked on, background colour doesn't show on links scrolls through pages. this smooth scrolling , changing background colour of links: $('a').click(function (e) { e.preventdefault(); var href = $(this).attr('href'); $("html:not(:animated),body:not(:animated)").animate({ 'scrolltop': $(href).offset().top }, 700, 'swing'); }); $('#nav a').click(function () { $('#nav a').css("background-color", ""); $(this).css("background-color", "#333333"); }); this when user manually scrolls through page , background colour on links change: $(window).scroll(function () { var href = $(this).scrolltop(); $('.link').each(function (event) { if (href >= $($(this).attr('href')).offset().top - 1) { $('.link').not...

javascript - React + Backbone, Target container is not a DOM element -

note: react error being thrown. so trying experiment render post component backbone router based on page. know not typically things way, things can messy , such. again it's experiment . so have following route in backbone (note react call): aisiswriter.routers.posts = backbone.router.extend({ writer_posts: null, posts: null, mountnode: $('#blog-manage'), routes : { '': 'index' }, initialize: function() { this.writer_posts = new aisiswriter.collections.posts(); }, index: function() { var options = { reset: true }; this.writer_posts.fetch(options).then(this.postsrecieved, this.servererror); }, // deal posts received postsrecieved: function(collection, response, options) { this.posts = collection; // walk through posts. $.each(this.posts, function(key, value){ // value array of objects. $.each(value, function(index, post_object){ react.rendercomponent(new post({post: post...

python - How to make chaco plots use predefined colormap scale? -

i have set of data represents thermocouple values @ multiple points on time. using chaco have managed plot heatmap of thermocouple locations, slider lets me pick time step want displayed. purpose of compare how dataset changes on time. the problem having colormap scale changes based on max , min values shown on screen, colormap scale stay fixed predetermined min , max. there easy way using chaco , traits? have looked through chaco documentation, none of examples have found cover situation. for simplicity, here pared down copy of code. have replaced data generated dataset of same shape, same value min , max. import numpy np enable.api import * chaco.shell import * traits.api import * traitsui.api import * chaco.api import * chaco.tools.api import * ## random data data11 = np.ones([3,5,100]) print data11.shape in range(3): j in range(5): k in range(100): data11[i,j,k] = np.random.random_integers(1100) class heatplots(hastraits): plot = instance(plo...

java - How to improve ugly catch block using exception instanceof -

please pay attention: caller throws parentexception only!! say aexception , , bexception inherit parentexception . in method af , throws aexception , bexception , parentexception . void af() throws aexception, bexception, parentexception {} the method caller calls af , throw parentexception only. void caller() throws parentexception here lost information of subclasses of parentexception. the method rootcaller calls method caller , rootcaller can catch parentexception thrown caller , using following exception process catch block: void rootcaller() { try { caller(); } catch(parentexception e) { if(e instanceof aexception) { ...... } else if(e instanceof bexception) { ...... } else if(e instanceof parentexception) { ...... } else { ...... } } this ugly , easy forget subclass of parentexception if subclasses many. is there anyway improve such code? current answer can not give me idea: ...

Allow formatting of text in django form (Like the text editor on this site)? -

with basic textfield on django, user can indent, , that's it. i'd allow centering of text, bold, italics, lists, etc. messed tinymce, unless there's i'm missing, outputs html every time. messing tinymce, or should take different route? if sure variable safe (doesn't contains harmful html code) can mark safe. render text without escaping html tags. {{ variable|safe }}

Scala passing method to supers constructor -

i'd have hierarchy base class can take function in constructor , derived class can supply method function. there 1 way below it's ugly. have declare child's function in constructor arg list of super's constructor. means function anonymous , not method of child class (though don't think care that). real code long , end difficult read, if had more 1 of these functions. thus: class a[t](s1: string, s2: string, w: (string, string) => unit){ def go: unit = { w(s1, s2) } } val externalwriter = { (s1: string, s2: string) => println (s1+s2) } val w1 = new a[string]("hello ", "world", externalwriter) w1.go case class b(s1: string, s2: string) extends a[string](s1, s2, w = { (a: string, b: string) => println ("class b:"+a+b) }){ def write: unit = go } val w2 = b("hey ","guys") w2.write w1.go prints "hello world" , w2.write prints "class b: hey guys". want there wa...

Drawing a Static Line Using Arduino, Gameduino 1.0 (VGA) and GLCD/TFT Display -

i super new @ this, please patient me. attempting design user interface on vga display using arduino uno , gamduino 1.0, , need drawing 2 axes (x , y). essentially, need draw 2 static lines on monitor x-axis pans left right on display, , y-axis 1/8 left of display, panning 1/2 top of display until bottom. hopefully makes sense. if it's static you'll want background (as opposed sprite). there's tutorial here on setting backgrounds: http://excamera.com/sphinx/gameduino/tutorials/frogger1.html i'm in process of similar i'll post code (gameduino arrived in mail today).

c# - Concatenate two columns in drop down list in MVC4 -

i have 3 columns in table (see below) , want concatenate 2 , 3 column text , column 1 value. how can in mvc dropdown? category table id categoryname categoryname_en 1 abc abc 2 xyz xyz 3 efg efg dropdown list needs looks like dropdownlist text value abc/abc 1 xyz/xyz 2 efg/efg 3 it below: public ienumerable<selectlistitem> getcategorylist(int selectedcatid) { // assuming getcategoriesfromdb returning ienumerable of category return getcategoriesfromdb() .select(cat => selectlistitem { text = cat.categoryname + "/" + cat.categoryname_en, value = cat.id, selected = selectedcatid == cat.id }).tolist(); } you can use method , send select...

Using Powershell to Loop check usernames from csv, loop through AD and add a number if needed -

here scenario, i wrote sql query extracts user accounts null username our student information system. lets assume these newly enrolled students. want take list, has column of suggested usernames, done simple concatenation in sql query. want loop through csv , check make sure username doesn't exist in ad , if does, append next available number username. so in test environment have csv looks this. ( made testing) studentid,first,last,suggestedusername 12345,tony,test,testto 54321,tolly,test,testto i test ad environment have student named tommy test or testto, in case, powershell script should tell me tony test should testto1 , tolly test should testto2. making sense? the meat of script works, read csv, loop through ad , return testto1 line 1 of csv, problem not read line 2, script ends i have been playing around arrays in script here have far import-module activedirectory add-pssnapin quest.activeroles.admanagement $useraccounts =@() $useraccou...

javascript - Clean and Rebind Data using KnockoutJs Template -

so bind knockout template follows: first ajax, data pass data can call function named bindko: function bindko(data) { var length = data.length; var insertrecord = {}; if (length > 0) { insertrecord = data[data.length - 1]; //last record empty premlimviewmodel insert insertrecord.add = true; data.splice(data.length - 1, 1); //remove blank insert record } function prelims(data) { var self = this; var model = ko.mapping.fromjs(data, { copy: ["_destroy"] }, self); self.bidpriceformatted = ko.computed({ read: function () { var bidprice = this.bidprice(); if (bidprice) { if (!isnan(bidprice)) { var input = '<input type="text" value="' + bidprice + '"/...

shell - How to prevent bash script from putting all output into one line? -

i have following bash script top_script.sh #!/bin/bash # "usage: $0 jobname logfile" jobname=$1 logfile=$2 job_output=$($1 2>&1) echo ${job_output} >> "${logfile}" that supposed invoked this top_script.sh script_to_run.sh log.txt if script_to_run.sh has multiple echo statements, e.g. echo line 1 $0 echo line 2 $0 then in log.txt is line 1 script_to_run.sh line 2 script_to_run.sh i.e. output gets concatenated single line. suspect reason line #5 in first code block above. how can modify ensure separate echo s print separate lines in log.txt ? not matters, in case wondering, top_script.sh gets generated automatically form config file. echo "${job_output}" >> "${logfile}"

SQL Server : Regular Expression in Like -

i'm having trouble getting regular expression work in sql server. i take in comma separated list, each item string want match against. declare @list table ([searchtext] varchar(255)) insert @list ([searchtext]) select cast(item varchar) dbo.fnsplit(@ids, ',') update @list set searchtext = '%controller/action/' + searchtext + '%' then need find if match in tables. select id table1 t1 inner join @list l on t1.[url] l.searchtext the problem match 'controller/action/283' , 'controller/action/2834' so tried '%controller/action/' + searchtext + '[^0-9]%' , works. works on 'controller/action/2834' doesn't match against 'controller/action/283' when there's nothing after it. problem i'm having normal regular expression don't seem working in syntax cant '(\b|[^0-9])%' specify both possibilities, combined 'or': update @list set searchtext = '%controller/act...

r - Manually set order of fill bars in arbitrary order using ggplot2 -

Image
this question has answer here: change order of discrete x scale 5 answers i'm trying figure out how transform bar graph. right now, gears fill in numerical order. i'm trying able manually set order of gears fill in arbitrary order. all other examples have found tell me how order them in descending or ascending order based upon counts or values of data. i'm trying set order manually in arbitrary order. instead of 3-4-5, i'd manually tell want data presented 3-5-4, or 5-3-4. here have now: library(data.table) library(scales) library(ggplot2) mtcars <- data.table(mtcars) mtcars$cylinders <- as.factor(mtcars$cyl) mtcars$gears <- as.factor(mtcars$gear) setkey(mtcars, cylinders, gears) mtcars <- mtcars[cj(unique(cylinders), unique(gears)), .n, allow.cartesian = true] ggplot(mtcars, aes(x=cylinders, y = n, fill = gears)) + ...

C++ Tic tac toe program -

i writing tic-tac-toe program pretty basic c++ course , have problem that's stumped me bit. below code usermove() function takes input user , writes ' x ' char array board[2][2] . works of time, problem if user inputs row = 1 column = 0 , both board[1][0] , board[0][2] changed 'x'. does see why happening? //! function usermove(). /*! function usermove() takes 2 integer inputs terminal user, checks see if move valid one, , updates char array board. */ void usermove() //take player's move { //! int row stores user's first integer input. int row; //! int column stores user's second integer input. int column; cout << "enter row you'd x:"; cin >> row; cout << "enter column you'd x:"; cin >> column; //! if statement checks user has selected blank space //! next move. if space taken, user informed //! error message , usermove() function called //! rec...

javascript - Search and highlight in html with multiple keywords as a single string -

in javascript, given html string tags like: this string has different fonts . <b>this</b> <i>string</i> <span style="background-color: rgb(212, 239, 181);">has</span> <b>different</b> <i>fonts</i>. when user searches search term multiple words "different fonts". how can add highlighting make html string like: <b>this</b> <i>string</i> <span style="background-color: rgb(212, 239, 181);">has</span> <span class="highlight"> <b>different</b> <i>fonts</i> </span>. please note search term treated single string if words in quote, cannot search , highlight each word individually. utilize innerhtml + str.replace in javascript start placing div around content. <div id='content'> set content variable in javascript. var xyz = document.getelementbyid("content").inn...

ios - Basic Request: How to Get Text Input in Cocos2d Application -

i have thought simple task: create 2 input fields on scene , perform usual input methods on them (touch set input focus, allow text entry using on-screen keyboard, deselect field when "done" key pressed, re-establish input focus if field touched/selected again, etc.), usual functionality see in applications allow user text input. i have looked through of relevant forums ios development, stackoverflow, , have seen incomplete code snippets , vague references, of don't exist anymore. i thought simple task, seems think vague directions sufficient wants straight answer. can provide complete description of needs done accomplish task? thanks. p.s.: after realizing didn't provide complete information, environment , tools i'm using: library framework: cocos2d v2 development studio: xcode 5.1 target platforms: ios on iphone, ipad, , ipod touch devices (port android platforms in progress) minimum ios required: 6.1 if using cocos2d v3, use cctextf...

java - Null Pointer Exception Occurs only while comparison and not printing out values -

public static void main(string[] args) throws filenotfoundexception, ioexception { // todo code application logic here bufferedreader in1 = new bufferedreader(new filereader("595231gov_nov_13_assessed.txt")); bufferedreader in2 = new bufferedreader(new filereader("627231farsidetect.txt")); string id = null; int count = 0; string count_line=null; while((count_line = in1.readline()) != null){ if(count_line.contains("id: ")) count ++; } system.out.println(count); file1 [] file_1 = new file1[count]; in1 = new bufferedreader(new filereader("595231gov_nov_13_assessed.txt")); int = 0; string line = null; string relation = null; while ((line = in1.readline()) != null && != count){ if(line.contains("id:")){ file_1 [i] = new file1(); file_1[i].id = line; } else if(lin...

regex - Regular expression that both includes and excludes certain strings in R -

i trying use r parse through number of entries. have 2 requirements the entries want back. want entries contain word apple don't contain word orange. for example: i apples i apples i apples , oranges i want entries 1 , 2 back. how go using r this? thanks. using regular expression, following. x <- c('i apples', 'i apples', 'i apples , oranges', 'i oranges , apples', 'i oranges , apples oranges more') x[grepl('^((?!.*orange).)*apple.*$', x, perl=true)] # [1] "i apples" "i apples" the regular expression looks ahead see if there's no character except line break , no substring orange , if so, dot . match character except line break wrapped in group, , repeated ( 0 or more times). next apple , character except line break ( 0 or more times). finally, start , end of line anchors in place make sure input consumed. update : use following if performance...

c++ - Two-step copy elision to capture rvalue in constructor call as instance variable -

i trying rvalue instance of class: #include <iostream> #define msg(x) std::cout << x " constructor\n" struct x { int i; x(int i) : i(i) {msg("x");} x(const x& x) : i(x.i) {std::cout << "x copy\n";} x(x&& x) {std::swap(i, x.i); std::cout << "x move\n";} }; into instance variable x of class: struct { x x; a(x x) : x(x) {msg("a");} }; like so: int main() { a(x(1)); std::cout << a.x.i << "\n\n"; } without copies or moves being made . according these references, http://thbecker.net/articles/rvalue_references/section_01.html http://www.slideshare.net/oliora/hot-11-2-new-style-arguments-passing and many many posts on ( so please read end before flagging duplicate ), should rely on copy elision , conditions should satisfied if pass value . note there two copy elisions required, namely: constructor call -> constructor local...

EXCEL - I want to have a drop down which shows products a user can afford -

on sheet1 show user how money have available (amongst other things). on sheet2 have list of products (it's long list), product reference number, name , price. at moment have simple dropdown on sheet1 shows products on sheet2. able filter items appear in dropdown list based on user can afford. lets on sheet1 b4 amount of money have available, c4 dropdown list. on sheet2 a1:c190 list of products. thanks!

php - Fastest way to update orderning in MySQL -

say have list of items, generated database. sake of example, let's call them: item1 item2 item3 ... itemn say want allow drag of these items , place them in order want (i.e. can take item10 , place between item2 , item3, shows after item2). this means need update ordering of items after dragged item placed. efficient way of doing this? there trick or updating after? edit: would node-approach faster?\ node, mean each item linked next item. way, need update 3 nodes' children , else work. in example above, before drag had : item2.child = item3 , itemn-1.child = itemn , itemn.child = null . after drag, need update: item2.child = itemn , itemn.child = item3 , itemn-1.child = null is better implementation? doing this, can't figure out way display list of queries db ... well if talking ui way here is: say have 5 elements names each element has attr called "order" <ob1 order="1" name="1"> <ob1 order="2...

json - Android increase log cat's log messages -

i wondering if it's possible , go increase character limit of single log message logcat. trying dump data stored locally on android device (as json string), string quite large , gets cut off in log cat. any appreciated. you wouldn't. either break multiple lines, or write file instead of system log.

php - Can phpFire access server side session variables of a live website that you don't have access to? -

is possible extensions phpfire firebug access server side session variables? without access websites server. i want make sure don't put sensitive data server session variables. if not server side session variables safe outside server itself? thanks

python 2.7 - NLTK - How to use NER -

how can invoke ner nltk of results on first 2 hundred characters of each of txt files located in same directory? when try code: for filename in os.listdir(ebooksfolder): fname, fextension = os.path.splitext(filename) if (fextension == '.txt'): newname = 'ner_' + filename file = open(ebooksfolder + '\\' + filename) rawfile = file.read() parttouse = rawfile[:50] segmentedsentences = nltk.sent_tokenize(parttouse) tokenizedsentences = [nltk.word_tokenize(sent) sent in segmentedsentences] postaggedsentences = [nltk.pos_tag(sent) sent in tokenizedsentences] nerresult = nltk.ne_chunk(postaggedsentences) pathtocopy = 'c:\\users\\felipe\\desktop\\books_txt\\' nametosave = os.path.join(pathtocopy, newname + '.txt') newfile = open(nametosave, 'w') newfile.write(nerresult) ...