Posts

Showing posts from June, 2011

How can I flip the order of a 1d numpy array? -

this question has answer here: most efficient way reverse numpy array 6 answers i have simple 1d np.array. is there built in functions reverse it? for example = [0, 1, 2, 3] = [3, 2, 1, 0]? thanks gabriele it same regular arrays: b = a[::-1] note, creates view on array. if change original array, reversed 1 reflect it.

mysql - SQL wildcard between two strings -

suppose have 2 tables: table1 table2 id | citya | cityb id | cities_queue| 1 c 1 , b , d 2 s f 2 , b , c ,e 3 d m 3 , m , d , e i want return rows of table 2 includes citya , cityb specific order, first citya , after ( somewhere...) comes cityb. because of accepted result must (a , b , c, e). first thought use command find table2 rows include citya, using substr() receive part of cities_queue comes after citya , using like() again cityb. question is: possible use once like() holding string (citya) - % - (cityb) where % = wildcard find cities_queue include citya , cityb regardless of between them; if so, please provide right syntax. thanks not sure point if order of elements has important: http://sqlfiddle.com/#!9/83459/7 select t2.* table2 t2 inner join table1 t1 on t2.cities_queue c

CKEDITOR -- cannnot restore cursor location after DOM modification -

i've read excellent answer pretty same question. however, have tried every technique @reinmar recommended, , none of them seem work. the situation taking current html editor , wrapping pieces in span tags. set modified html , try restore user's cursor location. no technique works. here simple example reproduce issue: <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script> </head> <body> <textarea id="cktest"><p>sometimes lorem. sometime ipsum. dolor.</p></textarea> <script type="text/javascript"> (function () { var checktimeout; var bookmark; var storecursorlocation = function(editor) { bookmark = editor.getselection().createbookmarks(); }; var

c++ - Is it possible to sign in and load a user's desktop programmatically from a windows 7 service on the local machine? -

the problem: using windows 7 machine display information on monitor. machine hard reach , has no keyboard or mouse attached. after user logs onto machine using remote desktop, logs off, becomes stuck @ "press ctrl+alt+delete" screen , have plug keyboard , mouse sign in user account responsible displaying correct information on monitor. i developing windows service in c++ looks @ current sessions see when user logs in , out of remote desktop. want have service sign correct user , display user's desktop after user logs out. right stuck trying find way have service sign user account , display desktop on monitor. there anyway this? no. can impersonate user, load user's registry hive, , launch processes user's account, in vista , later disallow interactive services, can't interacts user desktop. can ipc (inter-process communication) between service process , running user process, via tcp, named pipes, , other means, if user logged in desktop. c

javascript - SlickGrid onSelectedRowsChanged not firing -

i have following issue slickgrid: left click row 1 (onselectedrowschanged fires expected) hold down control button left click row 2 (onselectedrowschanged fires expected) left click row 1 (onselectedrowschanged fires expected) let go of control button click row 1 (onselectedrowschanged not fire! if click on same row 1 cell before) issues described on step 6 above. here link jsfiddler showing issues: http://jsfiddle.net/fortesl/olj8otsj/1/ code attached: var grid; var data = []; var columns = [{ id: "title", name: "title", field: "title", width: 300, selectable: false, resizable: false }, { id: "priority", name: "priority", field: "priority", width: 200, selectable: false, resizable: false }]; var options = { editable: true, enableaddrow: true,

powershell - resolve object variable from foreach-object -

i'm trying extract files extention .sddb out of archives in folder extention .sdbz. here how tried it: from folder contains file test.sdbz get-childitem -filter "*.sdbz" | foreach-object {.\7za.exe x $_.name -o *.sddb} it seems $_.name not resolved becaus if use command 7za.exe x test.sdbz -o *.sddb from command line works fine. can me please? in advance! first of all, replies. found error , solution. i made mistake of thinking command works in cmd work in powershell. cmd version "7za.exe x test.sdbz -o.\ *.sddb" the -o.\ tell 7zip extract working directory. it works in cmd not in powershell. powershell version here how solved it: $workingdirectory = pwd dir -filter "*.sdbz" | foreach-object { .\7za.exe x $_.name -o"$workingdirectory" *.sddb} so $_.name part worked along. xd

algorithm - Determine if unique number has been seen from a range of numbers -

i trying find best, quickest , efficient way determine if number has been seen in range. example: key record: raffle event 1 (database key) tickets available: 1 - 1000000 (the range) ticket number 4 turned in. has been turned in event? ticket number 865401 turned in. has been turned in event? i've thought bit masks, storing data buckets, etc. none of these seem answer trying find. maybe not exist. we have 800,000 events, each event 1 million tickets. storing last number turned in, , lower rejected. want have finer granularity, need efficiency , storing each ticket impractical. data stored using sql any ideas? edit the best idea i've come far using bitmap. have 10 columns each event. each column stores 100,000 bits. should allow quick data retrieval, check if bit on or off. should 1mb of storage per event, or 100k per column read. i'm still searching alternative ideas or recommendations. you use bitmask if anticipate range moderate. else t

python - Stretching Data Over Entire x-axis -

Image
i plotted data using matplotlib , have large whitespace gap on end. ideas on how rid of it? (204 values plotted) fig, ax = plt.subplots() ax.plot(osnow,'r-',label="observations") ax.plot(rsnow,'b-',label='merra') plt.xlabel('year') plt.ylabel('snow depth (cm)') plt.title('station '+str(stations[c])+' snow depth correlations') ax.set_xticks(np.arange(0,205,12)) ax.set_xticklabels(['1979','1980','1981','1982','1983','1984','1985','1986','1987','1988', '1989','1990','1991','1992','1993','1994','1995','1996'], fontsize = 'small') ax.text(30.0,35.0,'r = '+str(corr[0])+'', ha='center', va='center') plt.legend(loc='best') plt.show() as @plonser said above, ax.set_xlim(0,205)

Python | Avoid previous value from random selection from list -

basically want code print out 5 wrong() func's without there being 2 in row of same text. , of course don't want luck. :) though don't worry part of printing out 5 wrong() s, want make sure if use function @ least twice 100% sure previous value won't same next. for example, want avoid: wrong! wrong! though still fine: wrong! incorrect! wrong! my code: import random def wrong(): wrong_stats=["\n wrong!","\n tough luck!","\n better luck next time!","\n not there yet!","\n incorrect!"] rand = random.choice(wrong_stats) rand3 = random.choice(wrong_stats) norep(rand,rand3,wrong_stats) def norep(rand,rand3,wrong_stats): if rand == rand3: same = true while same: rand = random.choice(wrong_stats) if rand != rand3: print(rand) break elif rand != rand3: print(rand) wrong() wrong() wrong() wrong() wrong()

java - IJ000305: Connection error occured -

i'm getting 2 exceptions when calling stored proc mdb. the first 1 shows nullpointerexception. second 1 talks lock owned during cleanup. i enabled tracing on org.jboss.jca, , seems connections fine. connection obtained(5b0032a7) not in use, , there no other connection requests before errors happen. to rule out multi-threading, updated code send 1 message mdb. there no other threads using connections. the whole thing runs locally on desktop. there mdb makes calls same datasource(all work fine), , once it's done (i verified it's done , connections closed), sends 1 message mdb errors below show up. why happening? exception#1: warn [org.jboss.jca.core.connectionmanager.listener.notxconnectionlistener] (thread-3 (hornetq-client-global-threads-1812940249)) ij000305: connection error occured: org.jboss.jca.core.connectionmanager.listener.notxconnectionlistener@5b0032a7[state=normal managed connection=org.jboss.jca.adapters.jdbc.local.localmanagedconnection@69fd

How make JMeter generate specific request and wait for the specific response -

i don't know how make jmeter generate specific request , wait specific response. me? i'm testing web application. there specific jobs data calculations. in case when run job, on ui progress bar shown , every second i'm getting intermediate server response. job calculations time take 1-2 hours. submit • request: o post post "https:/myserver/web/api/datasets/684/cluster?viz-id=9242" payload in json: {"dbtype":"unit","columnname":"type", "version":0,"useweight":false, "weightcolumnname":"", "useweightasattribute":false, "extraattributes":9, "ignorecolumns":[]} • response: o {"message":"ok","result":{"location":"http:/localhost:8000/async/result/340"}} check then need "location" response, , keep checking every second or posting location string in request • request: o "

node.js - npm not installing any module -

i new node.js. have installed node.js , tested installation ok. node -v , npm -v command showing version numbers. when install module it's not working. example when try install connect module using npm install connect, it's showing following result. c:\>npm install connect connect@3.3.5 node_modules\connect ├── utils-merge@1.0.0 ├── parseurl@1.3.0 ├── debug@2.1.3 (ms@0.7.0) └── finalhandler@0.3.4 (escape-html@1.0.1, on-finished@2.2.0) c:\> kindly me out. that installed it. installed "locally" (to current folder) , not globally. if want install globally use -g . npm install -g connect

java - How to modify the JSON data and return the updated JSON data -

we have requirement update json data in middle , need return updated json data using java. should support type of json data. ex: assume {object:{"color":"red","shape":"triangle"}} json data , in need update shape value rectangle , need return updated json data below: {object:{"color":"red","shape":"rectangle"}} for need pass element path ( element need update) , updatetext , json data java code. here methodcall: updatevalue("object/shape", "rectangle", "{object:{"color":"red","shape":"triangle"}}") we tried below code using gson library. code able update targeted json element, requirement return entire json data updated value. so please suggest how re-build json data updated text. below code tried update json data. public string updatevalue(string keypath, string updatetext, string jsontext) { string[] k

rest - Linkedin OAuth2 authorization code error -

i´m trying connect via linkedin auth2 java web application: added own app in linkedin. generate authorization url: https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=xxx&scope=r_basicprofile%20r_fullprofile%20r_emailaddress&state=dceefwf454us5dffef424&redirect_uri=http://localhost:9090/springmvc/token.htm introduce login/password linkedin in new popup. get successful request on redirect_uri previus, , take authorization code "code" generate accesstoken url make post with: https://www.linkedin.com/uas/oauth2/accesstoken?grant_type=authorization_code&code=yyy&redirect_uri=http://localhost:9090/springmvc/token.htm&client_id=xxx&client_secret=zzz get next error in response: {"error_description":"missing required parameters, includes invalid parameter value, parameter more once. : unable retrieve access token : appid or redirect uri not match authorization code or authorization code expired&quo

timer - Can't adjust Javascript quote rotator initial quote load time of first quote -

i'm having issues simple quote rotator. time between quotes perfect, , can adjust that. need adjust initial load time of first quote separately. it's on same timer rest of quotes, , initial quote needs populate upon page load. i'm not sure add javascript code accomplish that. <script type="text/javascript"> $(document).ready(function(){ var $quotes = $(".quote").hide(), timer = 3000, interval; var quoterotate = function(){ $quotes.filter(".current").fadein(timer, function(){ var $this = $(this); var $next = ($(this).next().length > 0) ? $this.next() : $quotes.first(); $this.fadeout(timer, function(){ $this.removeclass('current'); $next.addclass('current'); }); }); }; interval = setinterval(quoterotate, timer * 2.05); }); </script> you can set initial delay this: $(document).ready(function(){ var $quotes = $(".q

sass - Function to dynamically create classes from lists -

im new sass , i'm confused way lists work. have multidimensional list this: $stylethemes: { (15, bold, red), (12, normal, blue) } i want function makes class each list in $stylethemes , puts values of list class. output want above list this: .theme1{ font-size: 15; font-weight: bold; color: red; } .theme2{ font-size: 12; font-weight: normal; color: blue; } can show me how can this? in advance. the code produce desired results this: $stylethemes: ( (15, bold, red), (12, normal, blue) ); @for $i 1 through length($stylethemes) { .theme#{$i} { font-size: nth(nth($stylethemes, $i), 1); font-weight: nth(nth($stylethemes, $i), 2); color: nth(nth($stylethemes, $i), 3); } } however, you'll find isn't particularly flexible. you're better off using mappings property/values don't have guarantee specific order: $stylethemes: ( (font-size: 15, font-weight: bold, color: red), (font-size: 12, font-weight: n

Twitter Streaming Filter API: Not seeing tweets -

i'm dabbling twitter streaming filter api ( https://dev.twitter.com/streaming/reference/post/statuses/filter ). have 2 twitter accounts. 1 account i'm using api calls, other personal account i'm using testing. in api call, i'm using "follow" parameter follow tweets of many users (like 50), including personal account. however, when publish tweet personal account, see tweets , don't. 2 tests tweets sent, arrived long after tweet sent, maybe 5 minutes or (slow streaming standards). my question is, how api endpoint work? guarantee delivery of tweets users you're following or sample of tweets? , if guarantee delivery, why slow? deliver tweets have arrived after time stream connection made? thank you

Overwrite last field in last line using awk -

i overwrite last field (2 fields in total) of last line of file value -9. using command: awk 'end{$2=-9}1' file.txt > new_file.txt but doesn't seem work (no replacement done). why's that? ideas? thanks! you'll need print previous line, , can manipulate last line in end block before has been printed: awk 'nr > 1 {print prev} {prev = $0} end {$2=-9; print}'

css3 - jQuery / CSS create linear gradient with only one color -

in css, linear gradient css looks like: background-image: linear-gradient(blue, lightblue); this starts gradient @ blue, , ends @ lightblue. not pretty, serves example. now, if have start color? if start passed parameter color (imagine it's passed in mvc viewmodel)? example, may have been passed value of 'red', , have linear gradient starting 'red' subtly lighter color of red make nice gradient? would need know, or convert, 'red' hex values, , generate gradient stop color manipulation of hex number? there 'normal' way this? ie some trick convert 'red' hex value #a11634 some trick apply math 'make a11634 subtly lighter color'? or some gradient trick automagically create gradient 1 color, lighter version of color? here's simple solution save hassles of manipulating colours; instead of passing named colour gradient, set background-colour of element white gradient background-image , fading transpare

Perl - Trying to use sort method -

i don't know exact word i'm trying achieve in perl. i have variable named $var my $var = "10 60 20 70 30 60 30 50 50 40 40 30 40 20 50 10 60"; this dynamic value. @ moment predefined make easy understand. then split $var my $var1 (split //, $var); and point dont know im talking about. i want sort $var1 this 30 40 50 10 20 30 40 50 60 10 20 30 40 50 60 70 is there way achieve result? i tried researching sort none of results found covered issue. if used method 10 20 30... , on. the best sense can make of question want hierarchy of lists — each containing duplicates next list in sequence. there 3 occurrences of 60 in input , 2 in output. this solution works pushing each value onto first element of @groups doesn't contain value. once items placed, array reversed , each sub-array sorted in numerical order use strict; use warnings; use list::util 'any'; $var = "10 60 20 70 30 60 30 50 50 40 40 30 40 20 50 10 60&quo

regex - I need to match ID video of a facebook video link -

i need match id video of facebook video link: https://www.facebook.com/dibattista.alessandro/videos/ 689793084466092 /?pnref=story p.s. dibattista.alessandro dynamic; https or http; ://www.facebook.com/ , /videos/ static; /?pnref=story maybe not exist. i'm not pratic regular expressions. can me? you can use regex positive ahead this: \d+(?=\/\?|$) working demo

dump - A replacement for HoneyProxy (dumping requests into a directory like structure)? -

i'm looking http/https proxy capability of dumping requests directory structure. example if request example.com/path/example.html, example.html stored in somedir/example.com/path/example.html in local disk. know honeyproxy provides feature, has bug doesn't work code. other http/https proxies mite, burp, node-mitm-proxy,... dump traffic , don't give directory structure of requests. please suggest me other proxy has feature? you should able use mitmproxy https://github.com/mitmproxy/mitmproxy/blob/integrate_honeyproxy/scripts/core/dirdumper.py

c++ - What is an undefined reference/unresolved external symbol error and how do I fix it? -

what undefined reference/unresolved external symbol errors? common causes , how fix/prevent them? feel free edit/add own. compiling c++ program takes place in several steps, specified 2.2 (credits keith thompson reference) : the precedence among syntax rules of translation specified following phases [see footnote] . physical source file characters mapped, in implementation-defined manner, basic source character set (introducing new-line characters end-of-line indicators) if necessary. [snip] each instance of backslash character (\) followed new-line character deleted, splicing physical source lines form logical source lines. [snip] the source file decomposed preprocessing tokens (2.5) , sequences of white-space characters (including comments). [snip] preprocessing directives executed, macro invocations expanded, , _pragma unary operator expressions executed. [snip] each source character set member in character literal or string literal, e

java - Calculating Average from a CSV File -

i have csv file, format follows: city,job,salary delhi,doctors,500 delhi,lawyers,400 delhi,plumbers,100 london,doctors,800 london,lawyers,700 london,plumbers,300 tokyo,doctors,900 tokyo,lawyers,800 tokyo,plumbers,400 lawyers,doctors,300 lawyers,lawyers,400 lawyers,plumbers,500 hong kong,doctors,1800 hong kong,lawyers,1100 hong kong,plumbers,1000 moscow,doctors,300 moscow,lawyers,200 moscow,plumbers,100 berlin,doctors,800 berlin,plumbers,900 paris,doctors,900 paris,lawyers,800 paris,plumbers,500 paris,dog catchers,400 i want find average of total salaries. this code: ` import java.io.*; public class { public static void main(string args[]) { a= new a(); a.run(); } public void run() { string csv="c:\\users\\dipayan\\desktop\\salaries.csv"; bufferedreader br = null; string line = ""; int sum=0; int count=0; //string a=new string(); try { br = new bufferedreader(new filereader(csv)); try { whil

javascript - Jquery dialogs interfering between them -

i not js guy. have 2 js functions. $(document).ready(function () { $(function () { $("#dialog").dialog({ autoopen: false, modal: true, width: 500 }); $("#button").on("click", function () { $("#dialog").dialog("open"); }); }); }); function editar(id) { $.ajax({ url: "../controllers/editarevento_controller.php?idevento="+id, success: function (data) { $("#editarevento").html(data).dialog({ modal: true, width: 500 }).dialog("open"); } }); } how html buttons , divs like. <input id="button" type="button" class="botonanadir" value="+añadir evento"> <input type='button' class='botongris' onclick='editar(some id);' value='editar'/> <div i

How to add a url suffix before performing a callback in scrapy -

i have crawler works fine in collecting urls interested in. however, before retrieving content of these urls (i.e. ones satisfy rule no 3), update them, i.e. add suffix - '/fullspecs' - on right-hand side. means that, in fact, retrieve , further process - through callback function - updated ones. how can that? rules = ( rule(linkextractor(allow=('something1'))), rule(linkextractor(allow=('something2'))), rule(linkextractor(allow=('something3'), deny=('something4', 'something5')), callback='parse_archive'), ) you can set process_value parameter lambda x: x+'/fullspecs' or function if want more complex. you'd end with: rule(linkextractor(allow=('something3'), deny=('something4', 'something5')), callback='parse_archive', process_value=lambda x: x+'/fullspecs') see more at: http://doc.scrapy.org/en/latest/topics/link-extractors.html

android - what is the difference between Robolectric.setupActivity() and Robolectric.buildActivity()? -

i new robolectric ,please me understand , difference between these loginactivity = new loginactivity(); loginactivity = robolectric.setupactivity(loginactivity.class); loginactivity = robolectric.buildactivity(loginactivity.class).create().start().resume().get(); you should take @ implementation of setup method. after following call hierarchy find following lines robolectric class method setup() return activitycontroller.of(shadowsadapter, activityclass).setup().get(); activitycontroller class method setup() return create().start().postcreate(null).resume().visible(); no can compare custom call chain chain setup method. here code: https://github.com/robolectric/robolectric/blob/770f4bc5a95a58ea1cd1238e4b1d51977b1bb17a/robolectric/src/main/java/org/robolectric/util/activitycontroller.java#l210

angularjs - Custom filter not working angular js -

i creating custom filter in angular js html, <div class="box-body"> <div class="form-group"> <label>page-title:</label> <input type="text" required value="" data-ng-model="title" name="page_title" class="form-control" id="" placeholder="enter page title"> </div> <div class="form-group"> <label>page-alias:</label> <input type="text" value="@{{ title | replacespace}}" name="page_alias" class="form-control" id="" placeholder="auto-generated if left blank"> </div> this angular js code var app = angular.module('customangular', []); app.controller('customctrl', function ($scope) { app.filter('replacespace', function () { return function (input) { return input.replace(/ /g, &

java - How do I use generics to call a method with a Class parameter? -

i have class uses reflection manipulate other classes: package com.cw.cmt; public class container<t extends class<?>> { private final class<t> clazz; public container(final class<t> clazz) { this.clazz = clazz; system.out.println("expensive constructor " + this); } @override public string tostring() { return string.format("container [clazz=%s]", clazz); } } because these potentially expensive construct, want cache them in map constructed needed: package com.cw.cmt; import java.util.concurrent.concurrenthashmap; import java.util.concurrent.concurrentmap; public class containercache { private static final concurrentmap<class<?>, container<? extends class<?>>> cache = new concurrenthashmap<>(); public static <c extends class<?>> container<c> getcontainer(final class<c> clazz) { final container<? extends class&l

r - overlapping shape and character in ggplot legend -

Image
when plot points , text same colour, a , shape overlap in legend. can tell ggplot not draw a in legend? how? m <- data.frame(t=letters[1:16], xx=runif(16), yy=runif(16), g=rep(c("a","b","c","d"),4)) str(m) ggplot(m,aes(x=xx,y=yy,label=t,colour=g)) + geom_point(shape=3) + geom_text(vjust=0,hjust=0) + scale_colour_discrete() just add show_guide = f geom_text : ggplot(m,aes(x=xx,y=yy,label=t,colour=g)) + geom_point(shape=3) + geom_text(vjust=0,hjust=0, show_guide = f) + scale_colour_discrete()

Allow Maven to automatically create directories in Ubuntu -

i running maven 3.0.4 in ubuntu 12.04. have java version 1.7.0_25. trying use mvn package command, continually running errors, along lines of: failure executing javac, not parse error: javac: directory not found: /......../target/[some folder] i couldn't figure out understand basic googling because destination directory has exist. suggested way handle problem create ant script (i think). however, have no idea folders need created. not project i'm compiling, i've downloaded. can ant script still used and, if so, point me in right direction have never used ant script before, less created one, , quite accurately called ubuntu "noob"! full maven output requested directory is: flume-sources - containing flume.conf pom.xml src main java com cloudera flume source twittersource.java twittersourceconstants.java maven error is: andrew@andrew

shell - Bash script to hit enter to continue or enter new directory -

hi i'm trying script continue if enter hit or take input variable code is: echo " hit enter default directory or insert new directory" read var if [ var = *enter* ] echo "enter pressed" else echo $var fi please use enter me not knowing comes next this script prints "default directory" if enter pressed, , name of new directory if else entered: #!/bin/bash echo "hit enter default directory or insert new directory" read var if [[ $var = "" ]]; echo "default directory" else echo "new directory: $var" fi

three.js - Normal map in *.obj file -

in blender create normal map, export blender obj (wawefront) , there stored in *.mtl file "map_bump". map_bump have same bumpsacale. parramter in mtl file defines bumpscale in three.js? my mtl file: newmtl ship_white ns 0.000000 ka 0.000000 0.000000 0.000000 kd 0.656604 0.656604 0.656604 ks 0.433962 0.433962 0.433962 ni 1.000000 d 1.000000 illum 2 map_kd 2t3l.png map_bump 2t3l_normal.jpg currently not supported. can remove bump map file , map manually in three.js. loading texture. var bmap = three.imageutils.loadtexture('bumpmap.jpg'); you need traverse model , find it's material. e.g. object.traverse( function( node ) { if ( node instanceof three.mesh ) { // smoothing node.geometry.computevertexnormals(); console.log(node); } if (node instanceof three.mesh && node.material instanceof three.meshphongmaterial ) { // console.log(node); geometry

c# - How can I configure Ninject to inject my DbContext for use with ASP.NET Identity Framework? -

i'd use ninject inject dbcontext asp.net identity framework. at moment have following line in web.config file: <appsettings> <add key="owin:appstartup" value="owintest.identity.owinstart, owintest.identity" /> </appsettings> this causes configuration() method on class owinstart in owintest.identity project called. here's owinstart class: public class owinstart { public void configuration(iappbuilder app) { app.createperowincontext<imycontext>(this.getdbcontext); app.createperowincontext<applicationrolemanager>(applicationrolemanager.create); app.createperowincontext<applicationusermanager>(applicationusermanager.create); app.usecookieauthentication( new cookieauthenticationoptions() { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath =

php - How to get values from one form to another -

can 1 me values of 2 different dates when press button form? i'm able value of 1 date. php scripts: <?php require_once 'incs/functions.php'; require_once 'classes/database.php'; global $database; $from_date = isset($_post['from_date']) != "" ? $_post['from_date']: date('y-m-d'); $to_date = isset($_post['to_date']) != "" ? $_post['to_date']: date('y-m- d'); $urlp = "print_one.php? uid= $from_date"; ?> here's code button: <?php echo "<a onclick=\"return windowpop('".$urlp."', 700, 500)\" href='#'> <button class='btn btn-round btn-white btn-size:50px;' style='alignment- baseline:left-90px;'>print</button></a>"; ?> as can see, when press button "print_one.php" form opens "from_date" value. how both values of "from_date" , "to_dat

php - How can I pass an integer to an ORACLE database? -

i have pass parameters numbers php oracle. there way ? cause need delete row id given. if try oci_by_name get: "numeric or value error: character number conversion error ora-06512" here code <?php $conn = oci_connect('dbadmin', 'dbadmin', 'petloversdb'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ent_quotes), e_user_error); } $deleteoption = $_get['selectedid']; $categoryselected = $_get['selectedoption']; if($categoryselected == "pet type"){ $stid = ociparse($conn, "begin setting_package.delete_type(:p1); end;"); } oci_bind_by_name($stid, ':p1', $deleteoption); oci_execute($stid); oci_close($conn); ?> any suggestions appreciated. depends setting_package.delete_type procedure expect. if varchar2 handle inside pl/sql routine, otherwise pre-check

c# - Cache an object for two subdomains in asp.net -

we have added few more sub domains our organisation's website. 1 sub domain dedicated admin things editing pages , content, 1 handles gallery , main 1 responsible displaying normal website. in own respective app pool. the problem that, on normal webpage, have lot of pages load content database. fine in cases starting become problem. idea cache content displayed on webpages avoid having load database time. problem if create cache on webpage it's not shared other sub domains. what way resolve , have cache shared between our sub domains? create sort of wcf/console-project running in background serving cache? create windows service? since organisation don't have money go around , buying expensive solution not possible. i think use redis cache http://redis.io/ caching solution. can run on same server (or dedicated one) , fast enough practical use cases. all of webapps can share same instance of redis cache , using product being used larger community better

Symfony multiple routes pointing to the same action -

my symfony app has existing route, log/add calls function addaction successfully. recently i've had add variant of route has timestamp @ end so, log/add/1429228800 . need second route point @ same action first. my issue second route generates following error: no route found "get /log/add/1429228800" my routes set in yml following: log_add: pattern: /log/add defaults: { _controller: mybundle:default:add } log_add_timestamped: pattern: /log/add/{timestamp} defaults: { _controller: mybundle:default:add } you need 1 route log_add: pattern: /log/add/{timestamp} defaults: { _controller: mybundle:default:add, timestamp: null} set default value timestamp parameter ( null in example, can set else)

javascript - Return a user to last page visited on browser close/crash? -

i have page user filling out large multi-page form. i'm using garlic.js persist data localstorage on event of crash or misclick of closing browser. what's easiest way can go getting user last page filling out after logging in, in event of crash or browser closing? can use localstorage or cookies? new javascript simplest solution appreciated! in case page not have pre-requisites, can follow below steps: on page load, store url localstorage as input field changed, store value in localstorage now browser crash accidentally , reopen application. localstorage - fetch last page url , load browser as page loaded, assign inputs previous values localstorage.

javascript - How to resize window dynamically using angularjs -

well, i've been searching around how resize window cursor, didn't had succeed. my idea resize window inside of html page , able move around. guess need css experience so. could me? thanks! for description guess you're trying resize div or can use transitions: https://css-tricks.com/snippets/css/scale-on-hover-with-webkit-transition/ try using drag , drop: http://ngmodules.org/modules/ngdraggable ( example ) to use draggable use directive follows: 1) include library in index: <script src="ngdraggable.js"></script> 2) in module definition inject ngdraggable: angular.module('myapp', ['... , ngdraggable']); 3) append html tags ng-drag <div ng-drag="true" ng-drag-data="{obj}" ng-center-anchor="true" ng-drag-success="ondragcomplete($data,$event)"> draggable div </div> where ng-drag-success function when drag finished. so, can make box based o

c++ - My else if statement using a string is not working -

this question has answer here: if statement not working right? 5 answers after amount of time trying else if statement work, doesn't. program keeps returning first one, no matter input. please help. #include <iostream> #include <string> using namespace std; string arehap; int main() { cout << "are happy?" << endl; cin >> arehap; if (arehap == "yes" || "y") { cout << "good." << endl; } else if (arehap == "no" || "n") { cout << "bad." << endl; } return 0; } you should use this: if (arehap == "yes" || arehap == "y") { cout << "good." << endl; } else if (arehap == "no" || arehap == "n") { cout << "ba

php - login script redirects user no matter what -

i'm making login page website connects mysql database stores login details. when submit form redirects information regardless of whether or not login valid. i'm confused wrong. my form: <form name="login" action="edit_profile/index.php" method="post"> //redirects page regardless of has been submitted <fieldset> <legend>please enter login details</legend> <label for="username">username</label> <input id="username" name="username" type="text" value="" required/><br> <label for="password">password</label> <input id="password" name="password" type="password" value="" required/><br> <input type="submit" value="submit"/> </fieldset> the php script: <?php require_once "connectdb.

javascript - angularjs getting data from a url -

i want json data url , assign variable. use service looks this app.service('dataservice', function($http) { this.getdata = function(callbackfunc) { $http({ method: 'get', url: '/records/json/', }).success(function(data){ // data succesfully returned, call our callback callbackfunc(data); }).error(function(){ alert("error"); }); } }); and controller looks this app.controller('rectrl', ['$scope', function($scope, dataservice){ dataservice.getdata(function(dataresponse) { $scope.fields = dataresponse; }); .... but error typeerror: cannot read property 'getdata' of undefined . dont know doing wrong. appreciate help. you not injecting service ( dataservice ) controller: app.controller('rectrl', ['$scope', 'dataservice', function($scope, dataservice){ dataservice.getdata(function(dataresponse) { $sc

performance - Mysql is slow in some cases while using 'LIKE' -

i have large table 60million entries. lets call table have bigtable , column tracking_code (of type varchar(8)). when use query select * bigtable tracking_code 'sdmasgg_'; it takes 0.75 seconds execute whereas query select * bigtable tracking_code 'sdma_ggh'; takes more 9 minuites. i intrigued selectivity shown mysql towards location of '_' my comment partially correct, though made mistake of thinking index wasn't used if wildcard anywhere other end of string in comparison. mysql btree indexes can used in comparisons long the argument constant string not start wildcard character if have wildcard in middle of string, use characters beginning first wildcard. in second example, means query uses index match "sdma". after that, scan remaining rows find match. only part before first wildcard serves access predicate. remaining characters not narrow scanned index range—non-matching entries left out of result.

javascript - Disabling default button action from the iframe parent -

i have website includes kinds of websites using iframe element, wanted have option disable default submit action of button elements inside iframe(i have overcome cross-origin problems). now, first, tried adding 'disabled' attribute button elements inside iframe , works perfectly, found looks awful on websites(css issue) have focused on adding new click event handler return false , prevent default action. tried first on live website(without iframe), chrome console running this: // disable click handler $('button').off('click') // submit form without handler $('button').bind('click', function(event) { event.stoppropagation(); return false; } ); and disables submit action. however, when tried same approach iframe: <iframe id="iframe" src='http://somewebsite.com'></iframe> <script> var element = $($('#iframe').prop('contentdocument')).find('button').get(3); $(element).off(&

Spring/Eureka/Feign - FeignClient setting Content-Type header to application/x-www-form-urlencoded -

when use feignclient setting content-type application/x-www-form-urlencoded instead of application/json;charset=utf-8 . if use resttemplate send same message message header content-type correctly set application/json;charset=utf-8 . both feignclient , resttemplate using eureka service discovery, , discovered problem debugging http message received server. the controller on server side looks this: @restcontroller @requestmapping("/site/alarm") public class sitealarmcontroller { @requestmapping(method = requestmethod.post) @responsebody public responseentity<raisealarmresponsedto> raisealarm(@requestbody raisesitealarmrequestdto requestdto) { ... } my feignclient interface in service calls alarm looks this: @feignclient("alarm-service") public interface alarmfeignservice { @requestmapping(method = requestmethod.post, value = "/site/alarm") raisealarmresponsedto raisealarm(@requestbody raisesiteal

ruby - Redirect To Same Page In New Domain after Locale changes in Rails 3 -

This summary is not available. Please click here to view the post.