Posts

Showing posts from January, 2010

numpy - Python multiprocessing (joblib) best way for argument passing -

i've noticed huge delay when using multiprocessing (with joblib). here simplified version of code: import numpy np joblib import parallel, delayed class matcher(object): def match_all(self, arr1, arr2): args = ((elem1, elem2) elem1 in arr1 elem2 in arr2) results = parallel(n_jobs=-1)(delayed(_parallel_match)(self, e1, e2) e1, e2 in args) # ... def match(self, i1, i2): return i1 == i2 def _parallel_match(m, i1, i2): return m.match(i1, i2) matcher = matcher() matcher.match_all(np.ones(250), np.ones(250)) so if run shown above, takes 30 secs complete , use 200mb. if change parameter n_jobs in parallel , set 1 takes 1.80 secs , barely use 50mb... i suppose has related way pass arguments, haven't found better way it... i'm using python 2.7.9 i have re-written code without using joblib library , works supposed work, although not "beautiful" code: import itertools import multiprocessing import numpy

c# - can not find dynamic html select in code behind -

i have class named "row" has 3 item {property,instance,degree}. want show items or rows user , if changed third part of class edit it. code of generating rows dynamically, numberofinstance number of rows. <div id="hidden" class="hiddendiv"> <% string matn = ""; (int = 0; < numberofinstance ; i++) { row r= new row(); r = a[i]; matn+= " <div class='cmsdiv'>"; matn += "<input id='text"+i+"' class='labelhid' type='text'"+"value = '"+r.property+ "'/>"; matn += "<input id='text2" + + "' class='labelhid' type='text'" + "value = '" + r.instance+ "'/>"; matn += " <select id='select" +i+ "'class='drophid' runat='server'>"; matn += " <option value= '"+ "

Debugging Python code -

after few days still cannot figure out how make work on python (not experienced programmer). here code pasted , @ bottom, expected result: color_list = ["red", "blue", "orange", "green"] secuence = ["color", "price"] car_list = [] def create_list(color_list, secuence, car_list): num in range(len(color_list)): car_list.append = dict.fromkeys(secuence) car_list[%s]['color'] = color_list[%s] %num return car_list this result want achieve: >> car_list [{'color': 'red', 'price': none},{'color': 'blue', 'price': none},{'color': 'orange', 'price': none},{'color': 'green', 'price': none}] you can in 1 line particular scenario, assuming 'color' , 'price' constants. car_list = [{'color': color, 'price': none} color in color_list] see list compr

Basic file I/O in Matlab -

i trying read particular textfile matlab, , store float values matlab matrix. have found few different ways it, none work quite way want. think problem formatting of textfile. here first few lines of file: **k = 1, j = 1 37.9072 37.9072 37.872 37.9072 37.9072 37.5572 37.9072 37.9072 37.9172 37.9072 37.962 37.9552 37.9072 37.9222 37.9072 37.9322 37.9072 37.9332 37.9072 ** k = 2, j = 1 34.9249 34.9249 34.9349 34.9249 34.9679 34.9249 34.9249 34.9249 34.2439 34.9249 34.9249 34.9249 34.9249 34.9459 34.9249 34.9549 34.9249 34.6749 34.9889 **k = 3, j = 1 37.94501 37.94401 37.94501 37.94501 37.99501 37.96501 37.94501 37.94501 37.94101 37.93301 37.94501 37.94501 37.94501 37.94501 37.90501 37.94501 37.90001 37.94501 37.99801 the issues having that: 1) each number not separated tab, , instead separated multiple spaces, , 2) first row of each line after '**' contains 7 columns of data, , subsequent rows contain 6 columns of data. able read lines want using tline = fgetl(fid), how e

jquery - Count duplicates within observableArray and Display them -

i have observable array following data ["volkswagen", "toyota", "volkswagen", "toyota", "audi", "volkswagen", "toyota", "audi"] i know how can count duplicate values , display them within select box. like: volkswagen (3) audi (2) toyota (3) what best way achieve this? i'd use straightforward computed: viewmodel.collapsedmakes = ko.computed({ pure: true, owner: viewmodel, read: function() { var makes = {}, rv; // use object count them this.makes().foreach(function(make) { if (makes[make]) { ++makes[make]; } else { makes[make] = 1; } }); // build array rv = object.keys(makes).sort().map(function(make) { return make + " (" + makes[make] + ")"; }); return rv; } }); live example: var viewmodel = { makes: ko.observablearray([ "volkswagen", "toyo

node.js - Meteor file system -

i have question meteor file structure. i´m coming java maybe i'm thinking way complicated. when create new meteor project (using osx shell), creates folder /usr/myusername/projectname/ . inside you'll find the: project.js , project.html , project.css , .meteor folder. what want is: create structure like: /usr/myusername/projectname/ there want create server client folder. put client.js , server.js into. where set references? example following code in project/client/client.js : meteor.call('somefunc', someobj); i have in project/server/server.js following code: if (meteor.isserver) { meteor.startup(function () { meteor.methods({ 'somefunc':function(someobj){ calevent.insert(someobj); } }) }); } where in client.js tell server.js is? , how? long story short : don't have worry references, long put things belong in client under client/ , server-side stuff under server/ you're go. no ne

iOS swift - how to draw an ellipse with touch event -

Image
currently trying port old windows phone app iphone. ui looks this: i want know how following: draw solid ellipse on specific position, e.g. @ position x = 0, y = 0; the ellipse change color upon touch; touch position on screen, ellipse animated move specific position. i tried several tutorial on how override drawrect in uiview, couldn't work, can provide simple sample? thanks lot! edit: sample code highly appreciated. there aren't swift code on internet , samples not easy find... animating inside drawrect never recommended. why not put uiview on place want , animate coordinates of view? the uiview custom view responding touch , triggering drawrect new color. the parent view place these views on can respond touches , move ellipse view right position.

javascript - Famo.us: Issue with Dragging and Panning -

i added 2 draggable containersurfaces (dragbox1 & dragbox2) onto transparent containersurface (panlayer), draggable. enables panning while enabling single dragging of 2 boxes. this worked in famo.us 0.2, ever since started using version 0.3 dragging box activates panning. how stop drag-event propagating? define(function(require, exports, module) { var engine = require('famous/core/engine'); var containersurface = require('famous/surfaces/containersurface'); var statemodifier = require('famous/modifiers/statemodifier'); var transform = require('famous/core/transform'); var draggable = require('famous/modifiers/draggable'); var maincontext = engine.createcontext(); var dragbox1 = new containersurface({ size: [200,200], properties: { backgroundcolor: '#ff0000' } }); var dragbox2 = new containersurface({ size: [200,200], properties: {

ReactJS - props vs state + Store designing -

imagine following: you're writing 'smart-house' application manages temperature in house. in view i'd to: see current temperature each room set desired temperature each room see whether air conditioning turned on/off each room there external device, communicating aplication via websockets (it periodically sending current temperature, air conditioning status). i see 2 options there: 1) create 1 'big' store containging data structures like: var _data = [ name: 'kitchen', currenttemperature: 25, desiredtemperature: 22, sensors: [ { name: 'air conditioning' state: 'on' } ... there might other sensors ... ] ] there temperaturemanager component (or similar). have state , fetch store periodically. distribute part of state descendants (ie roomtemperaturemanager, roomsystemsensormanager ), passing props. if changes (for example, temperature in bedroom), fetch data s

mysql - delete a comment in a post with FOREIGN KEY -

i have post , comment structure, , change adding foreign key: posts: create table if not exists `posts` ( `id` int(11) unsigned not null auto_increment, `user` varchar(40) not null, `text` varchar(500) not null, primary key (`id`) ) engine=innodb default charset=utf8mb4 auto_increment=1 ; post's comments: create table if not exists `comments` ( `id` int(11) unsigned not null auto_increment, `postid` int(11) unsigned not null, `user` varchar(40) not null, `texto` varchar(3000) not null, primary key (`id`), foreign key (`postid`) references posts (`id`) ) engine=innodb default charset=utf8mb4 auto_increment=1 ; so, if user wants delete post: delete posts id=? , user=? and post has comments mysql show me: cannot delete or update parent row: foreign key constraint fails. my question is, posts/comments structure correct? should use foreign key? how delete post if has comments? hmm seems me need set cascade option. cascade option deletes

Set font face in android -

i want change textview font-face external font , : typeface = typeface.createfromasset(getassets(),"fonts/bkoodak.ttf"); tv1.settypeface(typeface); tv2.settypeface(typeface); tv3.settypeface(typeface); ... but form is't nice me. there way better? yes there better way. but have create own derived textview apply typeface. , use in xml layout. refer question more details: how make custom textview?

php - page break after certain tables -

my problem : have page several html tables want print. tables have many rows, other have not. want print first , second table (the big ones) in seperate pages , rest of them (small ones) 2 per page. how can put page-break want to? tried <style> @media print { table {page-break-after: left} } </style> but puts page break after each table, not want. anyone can help??? , regards! i put rule class, , apply class each table. @media print { table.break {page-break-after: left} } and html: <table class="break">

vba - Button in Excel to copy information about specific month from other table -

Image
so have 1 big table, includes lot of information. need make button or else, copy information massive table date, example, purchases made in november. here's principle of have , should get. this button copy data , paste other sheet. nice if there month list data validation, select month , press button , shows purchases made in month. this example of big massive table this using button , select drop down menu i use table achieve this. select top-left cell (labelled "nr.") , insert ribbon choose table. providing have no gaps in rows , columns automatically select data. then can use filter button on row heading date. date values in cells enable date filter options shown in screen-shot below. right-click options meet requirements, or can use custom filter option enter specific date ranges. no code required.

Start jQuery UI Slider From 10 -

i start jquery ui slider 10 , had set min value 10, starts zero. my code is _app.detailsdivinit = function() { debugger; $( ".slider" ).slider({ min: 10, max: 60, step: 1 }) .each(function() { var opt = $(this).data().uislider.options; debugger; //get number of possible values var vals = opt.max - opt.min; // space out values (var = 0; <= vals; i+=opt.step * 20) { debugger; var el = $('<label>'+(i + "-" + (i + opt.step*20) )+' <div class="tickmark"></div></label>').css('left',(i/vals*100)+'%'); $( ".slider" ).append(el); } }); i gave value 10 still starts zero, , don't know why. not sure trying ranges though (there's 50 units min of 10 , max of 60, can't divide 3 20 sized blocks). anyhow, see if below closer looking - replace block

c# - TestAccelerometer implementation for Window Phone -

problem my application use accelerometer data via microsoft.devices.sensors.accelerometer class now wanna write unit or codedui tests, reason need have special test implementation of accelerometer controlling returned data in theory have 3 options: create subclass of accelerometer - impossible because accelerometer sealed class by using reflection replace implementation of accelerometer @ run-time - isn't best option imho create subclass of sensorbase<accelerometerreading> - option i have decided go #1 , implement testaccelerometer child of sensorbase<accelerometerreading> and here have problem: `error cs1729 'sensorbase<accelerometerreading>' not contain constructor takes 0 arguments` error pretty clear have looked in decompiled code ( jetbrains dotpeak tool) , don't found constructors @ all. questions how can found proper constructor use in testaccelerometer implementation? decompiled code microsoft.device

c# - ASP.NET label is null -

i'm trying make website c#. i've masterpage , there devexpress dateedit, 4 devexpress dropdownlists, 1 button , 1 label. i've method this: protected void dropdownnolar_selectedindexchanged(object sender, eventargs e) { var halisaha = (from veri in veriler.tum_halisahalars veri.il == dropdownil.text && veri.ilce == dropdownilce.text && veri.mahalle == dropdownmahalle.text && veri.no == dropdownnolar.text select veri).firstordefault(); if (halisaha != null) if (halisaha.description != null) lbldescription.text = halisaha.description; } and masterpage's aspx code: <%@ master language="c#" autoeventwireup="true" enableviewstate="true" codebehind="~/masterpage.master.cs" inherits="halisahakiralama.masterpage" %> <%@ register assembly="devexpress.web.

c# - WPF ComboBox Set using Grid DataContext -

i new c# wpf , tring set datacontext combobox xml below <grid name="groupeditarea" horizontalalignment="stretch" verticalalignment="stretch" background="#ffd8d8d8" margin="-14,0,192,0"> <label content="group name" fontsize="18" horizontalalignment="left" margin="116,50,0,0" verticalalignment="top" width="136"/> <label content="group type" fontsize="18" horizontalalignment="left" margin="116,123,0,0" verticalalignment="top" width="136"/> <textbox x:name="groupgroupnametxt" horizontalalignment="left" fontsize="16" height="31" margin="368,50,0,0" textwrapping="wrap" text="{binding path = groupname, mode=twoway, stringformat=\{0:n3\}, updatesourcetrigger=propertychanged}

How do I solve unclear iOS crashes in crashlytics? -

this error in crashlytics: thread : crashed: webthread 0 libobjc.a.dylib 0x344e4f46 objc_msgsend + 5 1 uikit 0x295ebe51 +[uiviewanimationstate popanimationstate] + 320 2 mediaplayer 0x278278bb -[mpvolumeslider _layoutforavailableroutes] + 1410 3 mediaplayer 0x27826505 -[mpvolumeslider layoutsubviews] + 60 4 uikit 0x295b7023 -[uiview(calayerdelegate) layoutsublayersoflayer:] + 546 5 quartzcore 0x28fd7d99 -[calayer layoutsublayers] + 128 6 quartzcore 0x28fd35cd ca::layer::layout_if_needed(ca::transaction*) + 360 7 uikit 0x295c9c03 -[uiview(hierarchy) layoutbelowifneeded] + 138 8 uikit 0x295cf0a3 -[uislider setvalue:animated:] + 178 9 mediaplayer 0x27826bfb -[mpvolumeslider volumecontroller:volumevaluedidchange:] + 78 10 mediaplayer 0x2788a995 -[

javascript - jquery save background-color in local storage -

i'm trying save change in background-color in local storage after button click, it's not saved when refreshing window. have forgotten something? $(".btn-secondmenu").click(function(){ $(".btn-secondmenu").css('background-color', 'red'); var status = $(".btn-secondmenu"); localstorage.setitem(".btn-secondmenu", status); }); you need set color variable status . current code sets $(".btn-secondmenu") - jquery object localstorage. $(".btn-secondmenu").css('background-color', localstorage.getitem(".btn-secondmenu")); //sets color localstorage on dom ready - getitem(). $(".btn-secondmenu").click(function () { $(this).css('background-color', 'red'); //use *this* set color current button var status = $(".btn-secondmenu").css('background-color'); //assign color value variable localstorage.set

interface - java.lang.StackOverflowError while calling a method -

i learning interface behavior. have created interface , implementer class, while calling method m1() got java.lang.stackoverflowerror. dont know why. can tell me proper reason behind !!!!!! here code : public interface employee { string name="kavi temre"; } public class kavi implements employee{ employee e= new kavi(); public static void main(string[] args) { kavi kt=new kavi(); kt.m1(); } void m1() { system.out.println(employee.name); //system.out.println(e.name); } } both sysout give same error : please tell me going on here ?? console output: exception in thread "main" java.lang.stackoverflowerror @ kavi.<init>(kavi.java:2) @ kavi.<init>(kavi.java:2) @ kavi.<init>(kavi.java:2) @ kavi.<init>(kavi.java:2) @ kavi.<init>(kavi.java:2) @ kavi.<init>(kavi.java:2) @ kavi.<init>(kavi.java:2) ..... when call kavi

ios - Limiting text read by VoiceOver from a UILabel -

i'm creating app similar mail (or messages or notes) displays uitableviewcell s contain message preview. text doesn't fit in uilabel , text truncated , ellipsis displayed automatically. works in app sighted users, when using voiceover entire text content of uilabel read aloud. not occur in mail - voiceover stops announcing text upon reaching ellipsis. how can obtain same behavior in app mail - enforce voiceover stop announcing text when reaches ellipsis? cell.messagepreviewlabel.text = a_potentially_really_long_string_here here subclass of uilabel want. note, have gone 0 effort optimize this. part you. overall recommendation, accessibility point of view, still leave it. overriding accessibility label portray portion of text in actual label questionable thing a11y perspective. use tool carefully! @interface cmpreivewlabel : uilabel @end @implementation cmpreviewlabel - (nsstring*)accessibilitylabel { return [self stringthatfits]; } - (nsstring*)s

architecture - Android application backend -

i want make android application display external message (for example: quotes, proverbs etc) daily. message should retrieved place other client device , configure messages end these messages should change everyday. how should end , how can android application retrieve configured message ? need server @ end same or can avail cloud services same ? best approach do? yes, need server. can start building server software on same machine android emulator , create them in parallel. you'll need choose language , web server framework suits thought process , style. if want use rest, instance, google "best rest server framework". hundreds of answers don't mean much, @ communities surround frameworks come back. @ user lists , how many questions exist on site. give better idea of whether can ask questions , answers when arise. making investment learning framework, spend little time deciding 1 going use, possibly trying few of them simple site returns kind of data

Android jni JNI_OnLoad error -

apiaccess.h #include <jni.h> #ifndef apiaccess_h #define apiaccess_h void init_data(jnienv* env); void toast(char* msg); #endif hello-jni.c #include <string.h> #include <jni.h> #include "apiaccess.h" jstring javastr( jnienv* env, jobject thiz ); void connectfunc(jnienv* env){ jninativemethod methods[] = {{ "stringfromjni", "()ljava/lang/string;", (void*)javastr}}; jclass clazz = (*env)->findclass(env, "com/testndk/ndk/hellojni"); int status = ((*env)->registernatives(env, clazz, methods, 1)); } jint jni_onload(javavm *vm, void *reserved){ // jni env function calls jnienv* env = null; if ((*vm)->getenv(vm, (void**)&env, jni_version_1_6) != jni_ok) return -1; connectfunc(env); init_data(env); toast("toast in jni_onload"); //error //return jni version need. default valur jni 1.1 return jni_version_1_6; } jstring javastr( jnienv* env, jobject thiz

javascript - Data with timestamp group to month(like Jan, Feb, March) and showing as total count for month in Highcharts -

with highcharts, possible draw column chart month wise(like jan, feb, march), data have timestamp, unable group data each month column. http://jsfiddle.net/k6onhj2x enter code here xaxis: { type: 'datetime', datetimelabelformats: { // don't display dummy year month: '%e. %b', year: '%b' }, title: { text: 'date' } } here chart on timestamp want convert monthwise. it not possible in highcharts , in highstock is. there's option datagrouping can put on plotoptions : plotoptions: { column: { datagrouping: { forced: true, units: [['month', [1]]] } } } this force chart group data in every 1 month. using highstock change of options, can change back. here's after changing options: jsfiddle as i've said there lots of options have change same, such legend , rangeselector , navigator ,

java - Getting duplicated data in tests -

when run following test case: @test(timeout=1000) public void shape_displaychar2_rot(){ string layout = "b....\n"+ ".....\n"+ "....b\n"+ ""; string expect = "shape z\n"+ "height: 5; width: 3; rotation: cw90\n"+ "..z\n"+ "...\n"+ "...\n"+ "...\n"+ "z..\n"+ ""; char newdc = 'z'; char dc = getdisplaychar(layout); shape shape = fitit.makeshape(layout,dc); shape.setdisplaychar(newdc); shape.rotatecw(); assertequals(newdc, shape.getdisplaychar()); string actual = shape.tostring(); assertequals(expect,actual); } i following failure: expected: shape z height: 5; width: 3; rotation: cw90 ..z ... ... ... z.. my actual code's result: actual: shape z height: 5; width: 3; rotation: cw90 b.... ..... ....b ..z ... ... ... z.. the string layou

c# - Not throwing error in compile time when casting base to derived class -

this question has answer here: compile-time , runtime casting c# 2 answers you have these classes shown below: public class { } public class b : { } you cast base class type of derived class a w = (b) new a(); b x = (b) new a(); this not work on run time because cannot convert base class derived class. but why there no compile time error ? why visual studio allowed me reach run-time before throwing error? there 2 types of casts once not allowed when classes have no common base , hence cast have no chance succeed. i.e. 'string' 'int'. such casts caught compiler , cause errors. casts have chance succeed - base derived have reasonable chance succeed. compiler allows such casts. i believe reason why (b)new a() allowed @ compile time if cast guaranteed fail because (b)someobjectoftypea can succeed , new a() 1 of such "

c# - Access database syntax error in update into statement -

first of know password reserved type of access database. have read post can put [password] , work. not working. have tried many ways , still, hope 1 help. oledbcommand cmd = new oledbcommand(); try { string query = "update [employe] set [username] ='" + txtnewuser.text +"', [password] ='"+ txtnewpass.text + "', [authorization] ='" + nudauthorizationlvl.value + "', [id] = '" + int.parse(txtexistingid.text); cmd.commandtext = query; cmd.connection = conn; conn.open(); cmd.executenonquery(); system.windows.forms.messagebox.show("info updated!!!"); conn.close(); } catch (exception ex) { messagebox.show("error" + ex); } { conn.close(); } i believe have comma right before where clause , quote before id. also, use parameters, avoid sql injection attacks: conn.open(); cmd.commandtext = "update [employe] set [username] =@username, [password] =@p

Error in "If" statement in R coding -

this code: #start of code# test1<-function(c,x){ high=0 low=0 samp=null samp=sample(c,x) for(i in 1:x){ if(samp[i]>1){high=high+1} else if (samp[i]<0){low=low+1}} c(high,low,mean(samp),var(samp),samp) } sim1 <-function(c,x){ replicate(nsim,{test1(c,x)})} size=10 a<-sim1(overall,size) listnormwor=null countnormwor=0 meannormwor=null for(i in 0:nsim-1){ **if (a[1+(size+4)*i]+a[2+(size+4)*i]==0)**{ countnormwor=countnormwor +1 (z in 5:(size+4)){ listnormwor=c(listnormwor, a[z+(size+4)*i])} meannormwor=c(meannormwor,a[3+(size+4)*i])} } countnormwor mean(meannormwor) var(listnormwor) simply, want if there no outliers (indicated '0' in first , second value of every 14 data points), count normal bucket , keep values calculate variance , mean later. but problem that, generates values , @ end, provides actual values want. for example, must satisfy length(listnormwor) = 10 * countnormwor but gives me ridiculous amount of data , when play around if sta

Android startActivityForResult() -

Image
i started learning android programming have problem starting activity result(using onactivityresult(), setresult()). first, there 3 activity - main, register, subactivity(but question regard 2 activity - main, register). registered of them 'androidmanifest.xml' this: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wakwakwak.iwak.myapp" > <uses-permission android:name="android.permission.vibrate"/> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".main" android:label="@string/app_name" > <intent-filter> <action android:name="androi

java - How to add the environment variables to the android Runtime.getRuntime().exec command? -

there's issue when run android runtime.getruntime().exec method. i have native binary file run on android , start java method runtime.getruntime().exec . running native binary file requires addition of environment variable. execute command: envsetcmd = {"sh", "-c", "export ld_library_path="+excbinfilepath+":$ld_library_path"}. it doesn't work when check environment variable command: sh , -c , echo $ld_library_path . i think reason when set environment variables start shell , when check command "echo" shell started. environment variables didn't work in shell check it. i think there 2 ways solve issue. 1 running 2 commands in 1 shell. tried use command: {"sh", "-c", "export ld_library_path="+excbinfilepath+":$ld_library_path", "-c", "echo $ld_library_path"}. unfortunately illegal. other add environment variables android user startup files. tried ec

using flask-migrate with flask-script and application factory -

i'm building flask application , decided try application factory approach time, got trouble flask-migrate , can't figure out simple solution. please note want pass config location option script manage.py: manager = manager(create_app) manager.add_option("-c", "--config", dest="config_module", required=false) then need create migrate instance , add command manager: with manager.app.app_context(): migrate = migrate(current_app, db) manager.add_command('db', migratecommand) but app instance not created yet, fails i know can pass config in environment variable , create application before creating manager instance, how using manager options? when use --config option have use application factory function know, function gets config argument , allows create app right configuration. since have app factory, have use deferred initialization extensions. instantiate extensions without passing arguments, , in app fac

regex - How to match everything except a particular pattern after/before a specific string constant -

ats(inline, const, unused) /* variadic macro */ ots(inline, const, unused) i'm trying match inline , const , unused keywords only in ats macro. tried ats([^,]*) matches inline keyword. edit : need change color of ats parameters. works on first parameter. (font-lock-add-keywords nil '(("ats(\\([^,]*\\)" 1 font-lock-builtin-face))) you can use anchored font-lock rule. it's search within search. code below searches ast( . once it's found, find end of argument list , performs search words within it. (defun foo () (interactive) (setq font-lock-multiline t) (font-lock-add-keywords nil '(("\\_<ats(" ("\\_<\\sw+\\_>" ;; pre-match form -- limit sub-search end of argument list. (save-excursion (goto-char (match-end 0)) (backward-char) (ignore-errors (forward-sexp)) (point)) ;; post-match form (goto-char (match-end 0)

haskell - No instance for MyClass arising from a use of `throwError' -

i have problem typing. started study monad transformers this article . little changed them example. now, code is: data pwderror = pwderror string type pwderrormonad = errort pwderror io isvalid :: string -> errort string pwderrormonad bool isvalid s | length s < 5 = throwerror "password short!" | otherwise = return true now, have error: no instance (error pwderror) arising use of `throwerror' in expression: throwerror "password short!" in equation `isvalid': isvalid s | length s < 5 = throwerror "password short!" | otherwise = return true could me compile program? you need make pwderror instance of the error typeclass . the following should sufficient, though haven't tried compile it: instance error pwderror strmsg = pwderror

javascript - React JS React Router Get Request Value -

i have url in react js site.i use react routes library routing. http://localhost:17086/home/index#/userlist?s=1515&showage=true how can read s , showage properties,and have grid , filter,sort data on it.is way use tag , use request bind grid. you can route params in props. this.props.routeparams.

javascript - How to serve an image in Django using jquery -

i trying update div element in html page png image gets returned django server. in client-side script send ajax post request on button click, have - $('#mybtn').click(function (event) { event.preventdefault(); $.ajax({ url: "/analysis", type: "post", data: { 'data': $("#analysis_list").val(), csrfmiddlewaretoken: document.getelementsbyname('csrfmiddlewaretoken')[0].value }, success: function (response) { $('#imagediv').html('<img src=' + response + ' />'); }, }); }); in views.py, have - def analysis(request): datafromclient = dict(request.post)['data'][0] pathtoimg = testanalytics(datafromclient) img = image.open(pathtoimg) response = httpresponse(content_type="image/png") img.save(response, "png") return response where testanalyti

c++ - Decode RSS characters (WP8.1/AppStudio) -

i've made simple rss reader using appstudio windows. problem rss feed xml contains characters need decoded in order fetched application. to more specific, character should shown "ë" being shown "& # x e b ;"(notice spaces between characters browser not auto-decode it.) i've tried making changes html2xaml.cs file, without success. if of guide me solving problem grateful. put me in right track , i'll sure find solution, if not have specific answer is. here full html2xaml file uploaded on pastebin: http://pastebin.com/egt3wxtm depending on version of app need use: httputility.htmldecode or htmlencode or system.net.webutility.htmldecode or htmlencode there more methods in class, url encoding , decoding.

java - Does anyone know how to work this out? -

what output produced following program? answer says 7 have trouble working out. public class practice { public static void main(string[] args){ int = 5; int b = g(i); system.out.println(b+i); } public static int f(int i) { int n = 0; while (n * n <= i) {n++;} return n-1; } public static int g(int a) { int b = 0; int j = f(a); b = b + j; return b; } } i assume main getting called. here list of steps happen g gets called 5 parameter. then in function g , f gets called g 's parameter, 5 in function f n set zero, while loop called , every time n*n less or equal parameter, 5, n incremented. below outlines while loop. 0*0 less 5, increment n 0 1 , continue. 1*1 less 5, increment n 1 2 , continue. 2*2 less 5, increment n 2 3 , continue. 3*3 not less 5, break out of loop. n-1 , 3-1=2, gets returned called, in variable j in function g . b ge

mysql - PHP use variable of class in other class -

i know php new classes-stuff. - love it. here problem: i'm writing class stuff around account-managements. (e.g. create new account, account details, check if account exists .... ) within class need mysql-requests. therefor i'm using medoo-class ( http://www.medoo.in ). class acc{ // attributes public static $account; public $pw; protected $error; public function acc_exist() { $database = new medoo(); $acc_count = $database->count("table_accounts", ["column_account" => acc::$account]); if ($acc_count == 0) {return true;} else {$this->error .= "account exists already!";}; }}; please note line: $database = new medoo(); and $acc_count = $database->count("table_accounts", ["column_account" => acc::$account]); here bring in medoo. , ["column_account" => acc::$account] acctually works. read in other posts, made $accounts public static . now call class this: $my_ac

java - GregorianCalendar year setting incorrectly -

i new java, , trying figure out oddity gregoriancalendar. seems year being set incorrectly (sometimes.) i have made following test function, illustrate problem: public static void testtime(calendar c) { simpledateformat sdf = new simpledateformat("yyyy/mm/dd hh:mm:ss"); sdf.settimezone(timezone.gettimezone("gmt+0")); system.out.println("---------------------------------"); c.settimeinmillis(0); date d = c.gettime(); system.out.println("time 0: " + sdf.format(d) + " (" + d.gettime() + ")"); c.set(calendar.year, 2000); d = c.gettime(); system.out.println("year 2000: " + sdf.format(d) + " (" + d.gettime() + ")"); system.out.println("---------------------------------"); } this function takes calendar object, , produces output should following: --------------------------------- time 0: 1970/01/01 00:00:00 (0)