Posts

Showing posts from February, 2011

sql server - context.SaveChanges() not persisting data in database -

im working on mvc app. when call context.savechanges update specific records. update not registered in database. not runtime error either. in notice records not updated. still see same values. insert functionality work perfectly. enter code here public admission update(int stuid){ vddata.vidyadaanentities context = new vddata.vidyadaanentities(); vddata.student_master studentmaster = new vddata.student_master(); studentmaster.student_id = stuid; studentmaster.student_first_name = this.firstname; studentmaster.student_middle_name = this.middlename; studentmaster.student_last_name = this.lastname; studentmaster.student_address_1 = this.address; studentmaster.student_address_2 = this.address2; studentmaster.student_city = this.city; studentmaster.student_state = this.state; studentmaster.student_pin_code = this.pincode; context.savechanges(); // here wont give kind of error. runs suc

python multiprocessing Pool with map_async -

i trying use multiprocessing package in python pool. i have function f called map_async function: from multiprocessing import pool def f(host, x): print host print x hosts = ['1.1.1.1', '2.2.2.2'] pool = pool(processes=5) pool.map_async(f,hosts,"test") pool.close() pool.join() this code has next error: traceback (most recent call last): file "pool-test.py", line 9, in <module> pool.map_async(f,hosts,"test") file "/usr/lib/python2.7/multiprocessing/pool.py", line 290, in map_async result = mapresult(self._cache, chunksize, len(iterable), callback) file "/usr/lib/python2.7/multiprocessing/pool.py", line 557, in __init__ self._number_left = length//chunksize + bool(length % chunksize) typeerror: unsupported operand type(s) //: 'int' , 'str' i don't know how pass more 1 argument f function. there way? "test" interpreted map_async 's c

sharepoint - MOSS 2007 on Active Directory 2012 -

i have client upgrading parts of windows server infrastructure windows 2012. have moss 2007 installation on same network currently. assuming wfes , app servers (which run sharepoint services) remain on windows 2008 installations app servers able continue run ad imports successfully? adjustments need made? or outright incompatible? i understand best answer upgrade sp 2010 or 2013 trying understand options. much.

c# - Is it possible to programmatically enforce a derived class to pass itself into a base class as the generic type? -

basically, have following scenario: public abstract class foobase<t> t : foobase<t> { public bool isspecial { get; private set; } public static t getspecialinstance() { return new t() { isspecial = true }; } } public sealed class concretefooa : foobase<concretefooa> { ... } public sealed class concretefoob : foobase<concretefoob> { ... } but, problem see here have done concretefoob : foobase<concretefooa> { ... } , mess class @ runtime (it wouldn't meet logic i'm trying achieve), still compile correctly. is there way haven't thought of enforce generic, t, whatever derived class is? update: end using generic parameter, t, in foobase<t> class, didn't list every method has out , in parameter, have use t. to answer question: no, there no compile time solution enforce this.

c++ - "Failed writing body" CURLOPT_WRITEDATA -

the below code response server using wsdl, here problem curl returns response unable print it. error: failed writing body failed writing data #include<stdio.h> #include<string.h> #include"../include/curl.h" size_t write_data(void *ptr, size_t size, size_t count, void *stream) { /* ptr - string variable. stream - data chuck received */ printf("%.*s", size, (char*)stream); } int main() { int res=0,i=0; char buffer[4098]="",buff[128]="",buf[256]="",buf7[30]="",buf6[30]="",buf5[30]=""; char machineid[]="subani"; char filename1[50]=""; int refno=0,paymode=0,taxtype=0; file *fbc; memset(filename1,0,sizeof(filename1)); sprintf(filename1,"/mnt/jffs2/response_details1.xml"); lk_dispclr(); lk_disptext(1,0,(unsigned char *)"sending request",0); lk_disptext(2,0,(unsigned char *)"please wa

css - Inline block adding extra space in firefox -

i have webpage have stacked div's inline-block properties. however, adds spacing between 2 div's in firefox. design consistent in safari , chrome. here's sample fiddle that. #main { display: block; } #sub11, #sub12, #sub21, #sub22, #sub31, #sub32 { display: inline-block; background:red; padding:0; //margin-right:-4px; margin-top:3px; margin-bottom:3px; } firefox adds space betweeb ghi , try row, while abc , ghi consistent other rows comes after try. the code: display: inline-block; will display spaces, have add float them appear directly after 1 another. try adding a: float:left; to #sub11, etc..

mysql - Questions regarding Pentaho Report designer -

i have datetime -type column in mysql. now, in report want use date part for a. grouping b. comparison i tried looking solution on net, couldn't find it. how use distinct in sql query in report designer. if design following query select count (distinct user_id) mytable it converts same to select distinct count (user_id) mytable please help. i never ran such behavior, but, anyway, think quick (but not best) workaround use following query: select count(0) (select distinct user_id mytable) t

android - Passing WebView from one activity to another -

i doing hybrid application. has 2 activities login , home. on login activity web view many java scripts loaded. want use same webview in home activity because takes time load javascript’s. as per android guide lines cannot pass view 1 activity another. how fix this?

sql - Database query for count -

i have 1 table with id | name | dept 1 | | d-1 2 | b | d-1 3 | c | d-2 4 | d | d-3 5 | e | d-1 6 | f | d-3 7 | g | d-4 now want fetch result like dept | count(dept) d-1 | 3 others | 4 can 1 me write query? you need use case group data d-1 , others : select case when dept = 'd-1' 'd-1' else 'others' end dept, count(*) total yt group case when dept = 'd-1' 'd-1' else 'others' end; see sql fiddle demo

spring mvc - Simplest way to limit user's ability to modify fields in a domain object? -

in restful spring mvc app, efficient way limit user's ability update domain objects? imagine movie service following url: "service/movie/id". there 2 groups of users, admins , basic users. while admins can use put request update properties of movie dto, basic users may update subset of them. what best way implement spring security? i have considered having separate urls admins , basic users, seems inelegant. you can use @preauthorize annotation checking roles. check out if it's need. http://static.springsource.org/spring-security/site/docs/3.0.x/reference/el-access.html#el-pre-post-annotations update can use @preauthorize("hasrole('role_user','role_admin')") multiple roles.

debugging - Unfold all values in Watch Window in Visual Studio -

is possible unfold sub-values of object @ once in watch window? i'm using vs 2012. here image ( http://i.stack.imgur.com/yyjim.png ) i found bugaid extention need. haven't found "free of charge" option functionality.

c++ - std::map - how to change key sorting? -

i have problem std::map . i'm using map list of pairs under specific index: map<string, list<pair<string, int> > > list; it's used in dijkstra algorithm. main problem map sorts string keys in alphabetical order, this: aaa, aa0, aa1, aab, ac1 = aa0->aa1->aaa->aab->ac1 but sort in different way: aaa, aa0, aa1, aab, ac1 = aaa->aab->aa0->aa1->ac1 is there solution this? read making own comparing class, have no idea how this. or maybe there's other way solve it? you have provide own comparison functor, must passed 3rd template parameter when instantiating map. example: struct comp { bool operator()(const std::string& lhs, const std::string& rhs) const { // implement comparison logic here } }; instances of class callable (hence "functor") 2 string parameters, , should return true or false based in strict weak ordering logic. then instantiate map using functor type: std::map<

java - share transaction among several connections -

i wonder possible share single database transaction among several physical connections? this question caused curiosity rather real task. encountered problem explain. assumed connection different, mistaken , cause different.

asp.net - jquery validation engine with dropkick -

i'm having problems getting posabsolute jquery validation engine plugin work jamie lotterings dropkick plugin. think having issue due dropkick hiding original <select> -element. , displays different <div> -s instead. this how bind validationengine form $(document).ready(function () { $(".theform").validationengine('attach'); }); , how append validation <select> <asp:dropdownlist runat="server" id="ddlattribute" cssclass="dk validate[required]" /> do have working solution these 2 plugins?

c# - asp.net CurrentUICulture and resx file -

in asp.net app want let user change profile language , load respective resx file. i have 2 global .resx files: localizedtext.resx localizedtext.pl.resx protected void page_load(object sender, eventargs e) { ... if (!ispostback) { setusersettings(...) } } and private void setusersettings(...) { ... thread.currentthread.currentuiculture = new system.globalization.cultureinfo("pl"); } setusersettings(...) used when user changes profile settings. the problem is fallbacking localizedtext.resx file instead of loading localizedtext.pl.resx i debbuged , currentuiculture "en_us" @ beginning of page_load. i tried set uiculture , culture properties didn't work. when use page.culture="auto" loads .pl.resx file when set browser language "pl" not want. any ideas? thanks i think should override page initializeculture method , set currentuiculture the

vector - Trouble with C++ Class -

i teacher @ independent boarding school , trying to write program in c++ randomly seat students @ tables in our dining hall sit different students , different staff members each week. ideally, on given period, not sit @ same table twice , many different students possible. have created program in python , works great (well, pretty good). variety of reasons, trying port on c++ (which not know @ all) can hand off boarding staff. both student , staff (as table capacities) read text files. have created 2 custom classes, 1 students , 1 tables, handle data. here 2 class header files: table.h #pragma once #include <iostream> #include "student.h" #include <vector> using namespace std; class table { // private class variables string staff; int numseats; vector<student> seating; public: table(); // default constructor table(string s, int n); table(const table& that) : staff(that.staff), numseats(that.numseats) { }

Simple way to use the SUM function in SQL -

so having issues creating sproc report new application reads calculations devices. these readings basic numbers , taken every week. trying combine calculations each month. i started toying around sum function since havent done sub-queries within a sum function before , have below: select (select sum(reading) readings (month(readings.readingdate) = 1) , meterid = 1) january1, (select sum(reading) readings (month(readings.readingdate) = 1) , meterid = 2) january2, (select sum(reading) readings (month(readings.readingdate) = 1) , meterid = 3) january3 readings year(readings.readingdate) = 2013 my tables , fields getting info pulled are: meters: meterid, metername readings: id, userid, meterid, reading, readingdate i'm aware not in stored procedure format right now, have feeling getting in on head current format because there 19 meters , if take 12 months of year going have 1 monster length of sproc feel simpler. awesome. thanks! use &quo

c# - Passing a method as a parameter with zero or more parameters for the passed in method? -

i'm trying code i've called 'trigger'. take object, function , kind of activation criteria. once activated, runs method on object. here's basic stripped down example. works expected now. example usage be: someobject myobj = new someobject(); mytrigger trigger = new mytrigger(myobj, "delete"); trigger.activate(); // calls myobj.delete(); now i've called invoke null parameters can go (i think). problem i'm having getting 'zero or more paramters' single parameter in function declaration. need thrid parameter when creating mytrigger parameters pass during invoke . or there better way it? i.e. can somehow pass object, function call , parameters single parameter? maybe 2 parameters? you have use delegates. // rewrite trigger constructor class mytrigger<ttarget> { public mytrigger(ttarget target, action<ttarget> action); public void activate() { this._action(this._target); } } // call

Cassandra Token Aware -

i have cassandra 1.2 cluster using vnodes (default of 256 per node). i'd predict placement of these vnodes physically within ring within client can more efficiently select coordinator node per query. i know vnodes randomly spread around ring i'd need query cassandra @ least once per client instance. any idea if it's possible? cassandra-sharp has looks stubbed class selecting endpoint it's row key: tokenawarestrategy. far can tell has no partitioning logic. has done before? alex cqlsharp has working implementation of tokenaware strategy. see cqlsharp wiki on details how use it. the datastax .net driver under heavy development. i've seen working on same kind of logic, unsure current state is.

javascript - push array value in variable using java script -

i have 1 string, want split , push in variable. try push array value in variable result tried. var region = "rajkot,jamnagar,surat"; var result; var array = region.split(','); (var i=0; i<array.length; i++ ) { alert(array[i]); result.push(array[i]); } but returning error result.push not function. how push value on variable , trying alert result variable. please solve query. thanks. you should initialize result variable var result = []; so final code be: var region = "rajkot,jamnagar,surat"; var result = []; var array = region.split(','); (var i=0; i<array.length; i++ ){ alert(array[i]); result.push(array[i]); } but split() returns array, for might unnecessary, unless wish business logic elements of array before adding them results.

table - Use of IN and EXISTS in SQL -

assuming 1 has 3 tables in relational database : customer(id, name, city), product(id, name, price), orders(cust_id, prod_id, date) my first question best way excecute query: "get customers ordered product". people propose query exists as: select * customer c exists (select cust_id orders o c.id=o.cust_id) is above query equivalent (can written?) as: select * customer exists (select cust_id orders o join customer c on c.id=o.cust_id) what problem when use in instead of exists apart performance as: select * customer customer.id in (select o.cust_id order o ) do 3 above queries return same records? update: how exists evaluation works in second query (or first), considering checks if subquery returns true or false? "interpretation" of query i.e.? select * customer c exists (true) the first 2 queries different. the first has correlated subquery , return want -- information customers have order. the second has uncorrelated sub

iphone - libpaypalmobile.a symbols not found in architecture error? -

Image
hi integrated paypal mobile sdk in app. got libpaypalmobile.a symbols not found in architecture i386 error. added required frameworks. when build project, got error. attached screen shot also. i googled much, cant find required answer. i used sdwebimage also, when place -objc --lstdc++ in other linker flags, error coming. please 1 can tell solution or suggestions. thanks in advance. did checked whether plugin listed in target -> build phases -> link binary libraries ? try enabling build active architecture only setting value yes

Optimizing kernel shuffled keys code - OpenCL -

i have started getting opencl , going through basics of writing kernel code. have written kernel code calculating shuffled keys points array. so, number of points n, shuffled keys calculated in 3-bit fashion, x-bit @ depth d (0 xd = 0 if p.x < cd.x xd = 1, otherwise the shuffled xyz key given as: x1y1z1x2y2z2...xdydzd the kernel code written given below. point inputted in column major format. __constant float3 boundsoffsettable[8] = { {-0.5,-0.5,-0.5}, {+0.5,-0.5,-0.5}, {-0.5,+0.5,-0.5}, {-0.5,-0.5,+0.5}, {+0.5,+0.5,-0.5}, {+0.5,-0.5,+0.5}, {-0.5,+0.5,+0.5}, {+0.5,+0.5,+0.5} }; uint setbit(uint x,unsigned char position) { uint mask = 1<<position; return x|mask; } __kernel void morton_code(__global float* point,__global uint*code,int level, float3 center,float radius,int size){ // index of current element processed int = get_global_id(0); flo

ASP.NET Development from Different cities at the Same time -

sir student, want develop asp.net website. there 2 developers in team. so, how can develop website @ same time 2 different locations (1 developer residing in 1 city , 1 in city). please guide me that. use source control system allow distributed teams. git/github 1 of first ones come mind. there bit of learning curve, should fit nicely needs. https://github.com/

mongoose - SchemeString, precedence of uppercase and match -

i add gender field accepts [mmff] , normalizes [mf] . here's schema: var userschema = new schema({ name: string, gender : { type: string, upper: true, match: /[mmff]/ } }); i wonder what's sequence of execution of schemestring functions. if uppercase executed before match , match [mf] . i have similar question concerning trim , match . thanks. answered aaron heckmann https://groups.google.com/d/msg/mongoose-orm/l5ztqdfbbwu/gyostzv1ehij upper , trim setters - when value assigned modified. match validator - executed later when calling .validate() or .save()

update query that works in both MYSQL and H2 -

i think have queries mysql , h2 both work can come 1 works on both? the table has foreign key own primary key , want copy field value down heirarchy. the mysql query looks this: update data p, data c set c.field=p.field p.id=c.linkid , p.level = 0; the h2 query looks this: update data c set c.field=(select p.field data p p.id=c.linkid , p.level=0) exists(select * data p p.id=c.linkid , p.level=0); the reason wanting common query production system mysql have unit tests in maven , want tests run anywhere , not have dependency on local mysql database.

iphone - iOS GameCenter Matchmaker not working -

i’m trying make custom matchmakingview using matchmaker. code below used find match. when run on 2 different devices different game center accounts, both match none connect match. stuck in while loop in infinity , never out. have missed something, need call connect match? - (void) findmatch{ gkmatchrequest *request = [[gkmatchrequest alloc] init]; request.minplayers = 2; request.maxplayers = 2; request.playerstoinvite = nil; nslog(@"start searching!"); [matchmaker findmatchforrequest:request withcompletionhandler:^(gkmatch *match, nserror *error) { if (error) { // print error nslog(@"%@", error.localizeddescription); } else if (match != nil) { curmatch = match; curmatch.delegate = self; nslog(@"expected: %i", match.expectedplayercount); while (match.expectedplayercount != 0){ nslog(@"players: %i", curmatch.playerids.count);

JQuery Not Being Parsed For Only Certain Users Even Though JavaScript Enabled in Browsers -

i have test system dozen test users. system built on zend framework using php5 , jquery. 3 of dozen users having problem login page; when click button nothing happens. problem occurs in firefox , chrome. the normal process flow when login submit button clicked, light validation happens username , password , login form submitted: //submits form $('#login_btn').live('click', function() { var uname = $('#form_30296_userid').val(); var pw = $('#form_30296_userpwd').val(); if(uname == '' || pw == '') alert('you must enter valid username , password.'); else $("form").submit(); }); i've confirmed it's not obvious code issue, works fine other users. here steps have taken far: added test alert [alert('!')] before other events happen onclick event. created notice appear if user not have javascript enabled in browsers personally verified javascript enabled in fir

How do you convert to percentage by using COUNT in SQL? -

for example, if want list percentages of males , females in 'employee' table. right? select sex, count (sex) [%] employees group sex; and if want list gender less 50%? following correct? select sex, count (sex) [%] employees group sex having count (sex) < 50% thank you. i believe you're looking for. select sex, (count(sex)* 100 / (select count(*) employees)) mypercentage employees group sex then can do having mypercentage < 50

d3.js - Converting seconds to minutes and formatting axes -

i have data in format of seconds. convert seconds data hours , minutes , display data along axis. example, i've been trying this: var xaxis = d3.svg.axis() .scale(x) .orient("bottom") .tickformat(function(d) {return d/60}); i see d3 has time formatter, can't seem display proper format. i'm looking a way in d3 convert data in seconds hours , minutes. how can this? var xaxis = d3.svg.axis() .scale(x) .orient("bottom") .tickformat(function(d) { var minutes = math.floor(d / 60000); var seconds = +((d % 60000) / 1000).tofixed(0); return (seconds == 60 ? (minutes+1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds); }); this convert milliseconds minutes , seconds.

css - IE9 Dropdown menu - Filter bug -

i have dropdown menu works fine in modern browsers, there weird things happening in ie9 . dropdown appears transparent or invisible in way, box-shadow visible. in addition, hovering fails when mouse off parent list item. i referring main navigation bar @ top: http://gratefulglass.viussandbox.co/ i placed red border on submenu's containing element, illustrate menu appears positioned correctly. any suggestions appreciated. the issue filter css properties you're setting on <ul> , <a> tags in code. ie9 render gradient backgrounds you, causes set haslayout flag on element internally, causes renderer treat element if had overflow: hidden; , can't override setting overflow: visible; it's not actually css rule, rather way internal rendering engine treat element when processing it. if remove filters filter: none; in override, or don't set them, should see work correctly again.

c# - Merge duplicate datatable records into XML document -

i have datatable category/subcategory records in format below: hierarchy id1 cat1 id2 cat2 id3 cat3 4 3105 mens 3195 shorts 3130 shorts 4 3105 mens 3195 shorts 3196 swim shorts 4 3105 mens 3177 knitwear 3118 jumpers 4 3105 mens 3177 knitwear 3178 cardigans 4 3105 mens 3177 knitwear 3814 v-neck knitwear i'm trying convert xml in format this: <category name="mens"> <categories name="shorts" /> <categories name="shorts" /> <categories name="swimshorts" /> <categories name="knitwear" /> <categories name="jumpers" /> <categories name="cardigans" /> <categories name="v-neck knitwear" /> but best can this: <category name="mens">

Java Major and Minor Garbage Collections -

i have been reading on garbage collection in java , q&a i'm confused types of garbage collection. let's take throughput collector example. (aka parallel collector). docs uses multiple threads minor collections , single thread major collections (same serial collector). now questions: what mean full gc: a) mean both minor , major collections done? or b) full gc == major collections? 1 it? if a), mean minor collection still done using multiple threads whereas major done using single? if b), mean both young & old generations cleared using single thread? also, 4. full gc affect oldgeneration or younggeneration well? thanks in advance. let me explain. let's take throughput collector example. (aka parallel collector). docs uses multiple threads minor collections , single thread major collections (same serial collector). here's understand. default, on newer systems, jvm uses 2 different garbage collectors young , old generati

c# - Converting Model to list in an MVC test -

i'm running tests using nsubstitute in vs2012 , i'm trying convert model list, or can count. here's code: [testmethod] public void startedgame() { // arrange var repo = substitute.for<igamerepository>(); ienumerable<game> expectedgames = new list<game> { new game{ gametypeid = 1, hasstarted = false, id = 1, isover = false, ispublic = true, maxplayers = 2, someonereported = false}, new game{ gametypeid = 1, hasstarted = false, id = 2, isover = false, ispublic = true, maxplayers = 2, someonereported = false}, new game{ gametypeid = 2, hasstarted = false, id = 3, isover = false, ispublic = true, maxplayers = 2, someonereported = false}, new game{ gametypeid = 2, hasstarted = false, id = 4, isover = false, ispublic = true, maxplayers = 2, someonereported = false}, new game{ gametypeid = 1, hasstarted = false, id = 5, isover = f

linux - Is it possible to include command line options in the python shebang? -

i have canonical shebang @ top of python scripts. #!/usr/bin/env python however, still want export unbuffered output log file when run scripts, end calling: $ python -u myscript.py &> myscript.out & can embed -u option in shebang so... #!/usr/bin/env python -u and call: $ ./myscript.py &> myscript.out & ...to still unbuffering? suspect won't work, , want check before trying. there accomplish this? you can have arguments on shebang line, operating systems have small limit on number of arguments. posix requires 1 argument supported, , common, including linux. since you're using /usr/bin/env command, you're using 1 argument python , can't add argument -u . if want use python -u , you'll need hard-code absolute path python instead of using /usr/bin/env , e.g. #!/usr/bin/python -u see related question: how use multiple arguments shebang (i.e. #!)?

namespaces - JAX-WS Spring premature end of file. Line 1 XML -

im using jax-ws spring , applicationcontext not show errors, when start tomcat generates xml error. my applicationcontext: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://jax-ws.dev.java.net/spring/core http://jax-ws.java.net/spring/core.xsd http://jax-ws.dev.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <wss:binding url="

datetime format - Haskell: File Access Time Formatted "yyyy-MM-dd" -

i'm getting quite lost in different date , time libraries available me in haskell. i'm trying format file modification time "yyyy-mm-dd". can show me how that? i've got code-snippet: main = times <- mapm getmodificationtime $ datafiles config -- datafiles returns [filepath]. -- i'd following: (putstr . unlines . map formatdate) times this i've attempted. please don't laugh! formatdate t = let (year, month, day) = togregorian $ utctday t in intercalate "-" $ map show [year, fromintegral month, fromintegral day] i know it's not specifications yet, because won't months , days left-filled zero. can fix that. figure there's more elegant way i'm after, why i've titled post i'm after rather current error i'm getting, which, sake of completeness couldn't match expected type 'utctime' actual type 'clocktime' . thanks whatever can give or clarity can provide. somethi

multithreading - How to make labels change in a C#.NET GUI-project -

i'm making application friend's birthday, window changing compliments supposed pop up. window freezes, however, , labels don't change. googled it, , read using backgroundworker in order seperate gui-thread changing process. still doesn't work. this code: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.threading; namespace projectl { public partial class form1 : form { private messagehandler thehandler = new messagehandler(); private backgroundworker thebackgroundworker = new backgroundworker(); public form1() { initializecomponent(); } private void startbutton_click(object sender, eventargs e) { startbutton.visible = false; thebackgroundworker.dowork += new doworkeventhandler(thebackgro

haskell - How to write a function that controls the data end decide if a data type exists? -

i wondering able control data type , decide whether entered data exists in haskell? for example: data ruler =ruler length price deriving(eq,show) data wallet = wallet colour ruler [pencil] deriving(eq,show) data pencil =pencil penciltype colour price deriving(eq,show) data colour =black | blue | green | red deriving(eq,show) data penciltype =leadpencil | pen | fountainpen | feltpen deriving(eq,show) type price =double type length =int so ideas? i want define function that: isruleravailable :: wallet-> bool if ruler available in wallet true else false i think you're misunderstanding how data types work in haskell. what wallet data type says is i store 1 ruler, colour, , pencils under tag wallet. this means wallet has 1 ruler in , can ever have 1 ruler in it. if wanted allow possibility of not storing ruler you'd use maybe ruler in data declaration, not ruler . then function bec

downloading - Android: Download thread stucks the app -

my android application gets stuck when downloading file until downloading finished. however,the downloading thread inherited aynctask , in background. can have , see wrong , how can modify code in order work? private class downloadfiletask extends asynctask<string, integer, string> { file destfile; private boolean openafterdownload; private exception failure; public downloadfiletask(boolean openafterdownload) { this.openafterdownload = openafterdownload; } @override protected void onpreexecute() { super.onpreexecute(); downloaddialog.setmessage(getstring(r.string.downloading)); downloaddialog.show(); } @override protected string doinbackground(string... params) { try { string url = params[0]; log.debug("downloading: " + url); string filename = url.substring(url.lastindexof('/') + 1); httpparams httpparams =

ruby - 'bundle show' results in different paths depending on user, but on same system and Gemfile.lock -

i have multiple users using cli app on same system. in order use unreleased patch, gemfile points specific commit on github of grit gem. app has gemfile.lock. users have same $gem_home , $gem_path locations set. now, 1 user 'cd app; bundle show grit' shows path '$gem_home/bundler/gems/grit-35b71d599549' (which exists cuz ran bundle install). odd-ball, 'cd app; bundle show grit' shows path '/nfs/home_dirs/odd-ball/.bundler/ruby/2.0.0/grit-35b71d599549' (which doesn't exist). bundler::giterror raised user. i have looked $bundle_* environment variables , ~/.bundle* configuration. i've verified has permissions $gem_home/bundler/gems. what other reasons account difference? thanks. i dug in , found came down file permissions individual user. specifically, in bundler.requires_sudo?: def requires_sudo? ... # if directory not writable, need sudo dirs = [path, bin_dir] | dir[path.join('*')] sudo_needed = dirs.fi

.htaccess - Browsing Windows File System Virtually in XAMPP with PHP & htaccess -

i'm developing app enable browsing windows file system in web browser. conceived of solution allowing wife @ photos stored on external hard drive connected network computer running xampp, alleviating need install software. i've gone on allow viewing movies, browsing music, etc. using various techniques serve content. woohoo! there no problems accessing file system using following in httpd.conf (apache config): <directory "h:/"> require granted allow rewriteengine on rewriteoptions inherit </directory> alias /externaldrive "h:/" originally, creating folder parameter using query string in url: index.php?q1=pictures then creating $path variable: if (isset($_get['q1'])) { $q1=($_get['q1']); $path=$q1."/"; } then feeding $path variable scan_dir: $scan_dir="h:/$path"; $files_or_folders = scandir($scan_dir); then iterating through results, changing $file_or_folder variable additional logic (not

c++ - Setting individual pixels of an RGB frame for ffmpeg encoding -

Image
i'm trying change test pattern of ffmpeg streamer, trouble syncing libavformat/ffmpeg x264 , rtp , familiar rgb format. broader goal compute frames of streamed video on fly. so replaced av_pix_fmt_monowhite av_pix_fmt_rgb24 , "packed rgb 8:8:8, 24bpp, rgbrgb..." according http://libav.org/doxygen/master/pixfmt_8h.html . to stuff pixel array called data , i've tried many variations on for (int y=0; y<height; ++y) { (int x=0; x<width; ++x) { uint8_t* rgb = data + ((y*width + x) *3); const double = x/double(width); // const double j = y/double(height); rgb[0] = 255*i; rgb[1] = 0; rgb[2] = 255*(1-i); } } at height x width = 80x60, version yields , when expect single blue-to-red horizontal gradient. 640x480 yields same 4-column pattern, far more horizontal stripes. 640x640, 160x160, etc, yield three columns, cyan-ish / magenta-ish / yellow-ish, same kind of horizontal stripiness. vertical gradients behave more weirdly

java - sql store procedure being called by multiple processes -

using: mysql server. i'm in situation need check if customerid exists before registering user in batch application. the problem different thread/process of same batch application can trying check if same user registered or not, , try create if not exist. after reading understand store procedure (createcustomer) select check if customerid not exists , calls insert register customer right way. if 10 batch processes try calling createcustomer store procedure same customerid @ same time ? happen in case ? possible same user created 10 times here ?

ios - position view relative to tab indicator -

i've been given ui uses uitabbarcontroller , , in 1 of tabbed viewcontrollers , view (an arrow uiimageview ) needs positioned relative tab indicator (the arrow needs point down @ indicator, centered along x-axis). used basic math emulate position based on known variables, , works iphone/pod in both landscape , portrait orientations, fails on ipad (it's little far right in both orientations - seems worse in landscape might perception). here's used: int visiblewidth = self.view.frame.size.width; int tabbarsize = self.tabbarcontroller.tabbar.frame.size.width; int tabsize = tabbarsize / [self.tabbarcontroller.viewcontrollers count]; int tabposition = 2; // hint should point @ 3rd tab int arrowiconwidth = hinticon.image.size.width; int arrowiconheight = hinticon.image.size.height; int tabemulationposition = visiblewidth / 2 - tabbarsize / 2; int taboffsetposition = tabemulationposition + ( tabsize * tabposition ); int iconposition = taboffsetposition + ( tabsize / 2 -

How can I dynamically change the visibility of a Durandal Route? -

i have durandal routes configured below. var routes = [ ....... more routes here..... { url: 'login', moduleid: 'viewmodels/login', name: 'log in', visible: true, caption: 'log in' }, { url: 'logout', moduleid: 'viewmodels/logout', name: 'log out', visible: false, caption: 'log out' }, { url: 'register', moduleid: 'viewmodels/register', name: 'register', visible: false, caption: 'register' }]; and working expected. able activate logout route in navigation when log in , log in button become invisible. have tried following code , despite not throwing errors not change visibility of in interface. var isloggedin = ko.observable(false); isloggedin.subscribe(function (newvalue) { var routes = router.allroutes(); if (newvalue == true) { (var k = 0; k < routes.length; k++) { if (routes[k].url ==

android - Java IO File not found exception -

i developed servlet , i'm trying access through android application. here important part async class. 'params[0]' url passed in parameter url url; bufferedreader reader = null; string s = ""; try { url = new url(params[0]); urlconnection con = url.openconnection(); reader = new bufferedreader(new inputstreamreader( con.getinputstream())); string line = ""; while ((line = reader.readline()) != null) { s = s + line; } } catch (malformedurlexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } catch (exception e) { e.printstacktrace(); } this works of times. sometimes, java.io.filenotfoundexception when take same url , try in browser works, application doesn't work no matter how many times try it. here logcat: 05-14 19:35:51.852: w/system.err(767): java.io.filenotfoundexception: http://192.168.10.105

asp.net - OutOfMemoryException Binding ObjectDataSource to GridView -

i'm trying use gridview show table pulled sql server. log of events. i've placed gridview control on page along objectdatasource control. i've configured : <%@ page language="vb" %> <!doctype html public "-//w" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title></title> </head> <body> <form id="form1" method="post" runat="server"> <asp:gridview id="gvhistory" runat="server" datasourceid="dshistory"> </asp:gridview> <asp:objectdatasource id="dshistory" runat="server" selectmethod="gethistoryrows" typename="aspdotnetstorefrontadmin.roiimporthistory"></asp:objectdatasource> </form> </body> </html> i've created class in app_code folder follows: imports system.data namespac

Should I learn node.js before starting with meteor? -

i'm coming java background, , needed app realtime data , push. i'm thinking of using meteor since seems easier way use node.js. my question need learn node.js before starting meteor ? , meteor suitable production application (i know haven't reached 1.0, experiences think) thank you. meteor not require knowing node.js in order build applications, long stay within boundaries of meteor abstracts away you. meteor young, "production-ready" depends on application is. write real-time banking application right now? no. ready mvps, demos, , straightforward consumer applications? sure, long understand limitations.

Swi prolog finding all the neighbours of a nod in a directed graph -

i have directed graph represented this: arc(1, 2). arc(1, 4). arc(1, 5). arc(3, 2). arc(3, 7). arc(4, 3). arc(5, 6). arc(6, 8). arc(7, 6). arc(9, 8). what need predicate put inside list nodes can go specific node. example node 1 resulted list should l=[2,4,5] because 1 can go 2,4 , 5. doesn't matter how done, matters result, nodes must in list. have tried in couple of ways failed. an example of how tried it: road(x,l,l2):- arc(x,y), not(belong(y,l)), append(l,[y],l2), road(x,l2,_). road(x,l,l). belong(y,l) predicate returns true if y found inside of l . , example when run road(1,[],l). result l=[2] , normal because predicate not written. when try make using recursion don't know put right stop recursion, hope understand want say. , tried way using fail didn't worked neither , don't remember how made it. hope can come solution fast :), in advance. your code need fair amount of corrections: here working version. road(x,l,l2) :- arc(x,

google analytics - Unique events are greater than total events -

i'm having issue unique events , total events. don't understand why unique events greater total events (image attached: https://analytics-a-googleproductforums-com.googlegroups.com/attach/584c3c65bd24cfec/screenshot%20at%202013-05-14%2017:00:40.png?gda=9qkpguyaaadqflbdoux1kz9vp-6pb8mh0qevsnjbcwpb2zqmxh9r_fqjw8mf6kyuxitghb4bde5x40jamwa1uurqdcgharkee-ea7gxymt0t6ny0uv5fiq&view=1&part=4 ). someone can explain how posible? santiago vázquez found thing: see "unique events" great "total events" when @ event category or action, put "event label" secondary dimension , event has been triggered times no label input. google analytics hasn't option "(not set)" particular dimension, doesn't show events in total events count, still counts "unique events" users executed particular event category / action.

oop in javascript binding dom elements to objects -

hi point in right direction question. i'm trying fathom object orientated javascript, having trouble getting head around binding dom elements objects. i make little animated widget type thing web page. widget simple drop down tabs , (like tabs actual folder) want tab drop down bit mouseover event raise mouseout. here current implementation, doesnt work @ moment it's mock http://bombinglish.com/ i want make class tabs , include open , close animation methods, methos add events, , other necessary fields. instanciate new object each tab. how do tell each object must must respond corresponding mouse events, or put way how bind dom element object? if using javascript presentation logic, don't think it's worth try , wild oo. if have @ top of every page, label tabs unique class name. in javascript file bind mouseover event on every dom element class name. perhaps, others have differing opinions on however.

Bad Exception after using a C++ class in IOS -

i'm trying add fuzzy search ios app have built using existing c++ implementation of double_metaphone maurice aubrey http://aspell.net/metaphone/ . i've renamed main class double_metaphone.mm, set file type c++ source , got project build. however getting exc_bad_access error after call doublemetaphone method. of app uses arc , see number of memory management things in double_metaphone.mm class. said suspicious of how i'm trying answer method. here relevant part of double_metaphone.h (i enclose method declaration in extern "c" per calling c++ method objective c ). void doublemetaphone(const char *str, char **codes); here relavant parts of method implementation in double_metaphone.mm void doublemetaphone(const char *str, char **codes) { int length; metastring *original; metastring *primary; metastring *secondary; int current; int last; current = 0; /* need real length , last prior padding */ length = strlen(str); last