Posts

Showing posts from August, 2011

map - Type check error in Haskell monad chaining -

i'm new haskell , i'm following example on rwh. i'm having problems following programs on chapter 14: import qualified data.map m type personname = string type phonenumber = string type billingaddress = string data mobilecarrier = honest_bobs_phone_network | morrisas_marvelous_mobiles | petes_plutocratic_phones deriving (eq, ord) findcarrierbillingaddress :: personname -> m.map personname phonenumber -> m.map phonenumber mobilecarrier -> m.map mobilecarrier billingaddress -> maybe billingaddress -- work findcarrierbillingaddress person phonemap carriermap addressmap = phone <- m.lookup person phonemap carrier <- m.lookup phone carriermap address <- m.lookup carrier addressmap return address -- not work: findcarrierbillingaddress person phonemap carriermap addressmap = retu...

statistics - R- Partial eta squared for repeated measures ANOVA (car package) -

i have 2-way repeated measures design (3 x 2), , i'd figure out how calculate effect sizes (partial eta squared). i have matrix data in (called a) (repeated measures) a.a a.b b.a b.b c.a c.b 1 514.0479 483.4246 541.1342 516.4149 595.5404 588.8000 2 569.0741 550.0809 569.7574 599.1509 621.4725 656.8136 3 738.2037 660.3058 812.2970 735.8543 767.0683 738.7920 4 627.1101 638.1338 641.2478 682.7028 694.3569 761.6241 5 599.3417 637.2846 599.4951 632.5684 626.4102 677.2634 6 655.1394 600.9598 729.3096 669.4189 728.8995 716.4605 idata = caps lower b b b b c c b i know how repeated measures anova car package (type 3 ss standard in field although know results in logical error.. if w...

shell - Read commands from text file and run it in Qshell -

i have file has commands written in lines. need read file , run commands written in in qshell. know can : ls < test.txt not documentation < command. please let me know if there other better way . the qsh utility accepts command file parameter , runs commands contained in file. qsh test.txt < standard redirection operator. ls utility not process stdin example list specific files not work way expect. the xargs utility execute specified command (utility) parameters stdin. xargs ls < test.txt assuming test.txt contains following lines: a b c it execute following command: ls b c you can limit number of parameters -n parameter. xargs -n 1 ls < test.txt this execute following individual commands: ls ls b ls c

regex - How to get the second occurrence of a Regexp match in Javascript -

i want 2 string following url, first -43.575285 , second 172.762549 http://maps.apple.com/?lsp=9902&sll=-43.575285,172.762549 i wrote regexp pattern re = /-?\d+\.\d{6}/; which works first value, there way matcher can continue search result string , give me second pattern occurrence? p.s remember ruby has $1-$9 reference occurrence. add g flag end... re = /-?\d+\.\d{6}/g; this g global . var matches = str.match(re); note won't work quite above if add capturing groups.

android - Restoring Application State on Phonegap -

i've develop android app phonegap, app need swicthing on toggle button, user can close app , running in background service. problem when close app , app again, initial state toggle button off. so, question how can saving/restroring app state on android , phonegap? i've read save & restoring webview in embedded phonegap app , still don't understand restorefrompreferences() , savetopreferences(out) can help? *sorry bad english as @geet said, localstorage need store datas , retrieve them later. according phonegap website, localstorage provides access w3c storage interface. can read here : http://dev.w3.org/html5/webstorage/#the-localstorage-attribute . to save toggle button position : <script> function ondeviceready() { // set togglebutton false default var togglebutton = window.localstorage.getitem("togglebutton"); if (togglebutton==null) window.localstorage.setitem("togglebutton", 'false'); // set default stat...

.net - What does "??" do in C#? -

this question has answer here: what 2 question marks mean in c#? 14 answers i found new , interesting code in project. do, , how work? memorystream stream = null; memorystream st = stream ?? new memorystream(); a ?? b is shorthand if (a == null) b else or more precisely a == null ? b : so in verbose expansion, code equivalent to: memorystream st; if(stream == null) st = new memorystream(); else st = stream;

html - TinyMCE forecolorpicker backcolorpicker addon to the bar -

as can see in: tinymce theres "forecolorpicker backcolorpicker" when add them following code nothing , cant find plugin add: tinymce.init({ selector: ".editabletext", inline: true, menubar: false, toolbar_items_size: 'small', plugins: [ "advlist autolink lists link directionality textcolor visualblocks paste", " ", "" ], toolbar: "forecolorpicker backcolorpicker" }); you need use this toolbar: "forecolor backcolor" otherwise tinymce won't able add buttons.

javascript - Wordpress related posts only show the last three posts in the category. Is there a way to randomize every related post? -

my wordpress related posts shows last 3 recent posts created in each category. hoping have show random posts in each category. older post can viewed. not last 3 created. here's code below. <?php $categories = get_the_category($post->id); if ($categories) { $category_ids = array(); foreach($categories $individual_category) $category_ids[] = $individual_category->term_id; $args=array( 'category__in' => $category_ids, 'post__not_in' => array($post->id), 'showposts'=>3, // number of related posts shown. 'caller_get_posts'=>1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { echo '<ul>'; while ($my_query->have_posts()) { $my_query->the_post(); ?> <div class="relatedpost"> <a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(175,98)); ?><br /> <center><h6><?...

Linq "Unable to create a null constant value of type 'System.Collections.Generic.List`1" -

exception while null unable create null constant value of type 'system.collections.generic.list`1'. entity types, enumeration types or primitive types supported in context. query list templist = context.businessentities.where(w => relatedbusinessentityguids.contains(w.businessentityguid)).select(s => s.name).tolist(); if theere no matching (null) getting error ,how resolve it,

maven - Missing resource bundle com.adobe.flex.framework:playerglobal:rb.swc:ko_KR:4.5.1.21328 -

facing issue while creating locale file maven build korean locale. rest of language resource bundle created korean locale giving problem. following error occur. [error] failed execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:4.0-rc2:compile-swf (default-compile-swf) on project ---: execution default-compile-swf of goal org.sonatype.flexmojos:flexmojos-maven-plugin:4.0-rc2:compile-swf failed: missing resource bundle 'com.adobe.flex.framework:flash-integration:rb.swc:ko_kr:4.5.1.21328

binary - PHP read file as an array of bytes -

i have file written using java program has array of integers written binary made loop on array , write using method public static void writeint(outputstream out, int v) throws ioexception { out.write((v >>> 24) & 0xff); out.write((v >>> 16) & 0xff); out.write((v >>> 8) & 0xff); out.write((v >>> 0) & 0xff); } i'm ask how read file in php . i believe code looking is: $bytearray = unpack("n*",file_get_contents($filename)); update: working code supplied op $filename = "myfile.sav"; $handle = fopen($filename, "rb"); $fsize = filesize($filename); $contents = fread($handle, $fsize); $bytearray = unpack("n*",$contents); print_r($bytearray); for($n = 0; $n < 16; $n++) { echo $bytearray [$n].'<br/>'; }

multithreading - How to get data from a thread to the UI in C# (How to use backgroundWorker) -

in application, using data grid view. data filled in data grid view in thread. how can data thread data grid view? how can use background worker this? (please find sample code below) please help. new c#. using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace ex1 { public partial class form1 : form { public form1() { initializecomponent(); datagridview1.columns.add("1", "sno"); datagridview1.columns.add("2", "time"); datagridview1.columns.add("3", "name"); } public void button2_click(object sender, eventargs e) { // data mythread , add new row datagridview1. //like, datagridview1.rows.add(sno,time,name); // strings mythread } #region event thtead (rx) public void mythread() { // each time button2 press, ...

python - Hard to find bug that involves strange physics behaviour in pygame code -

first i'll i'm pretty tired i've been 22 hours straight. anyway have funky physics problem in pong game. know old classic. have been looking @ code long time trying different variation, commenting out parts etc. , can't find damn bug! can give me hand, please? it's physics ball that's problem. bounces off top , bottom screen fine when going left fine. but can't send going right after collides paddle coming left. forces bounces off bit , forces it's way , on paddle?! however can send ball right when program bounce right after hitting 1 of top or bottom sides, don't think there wrong actual code moves ball right. but movement right opposite of desired physics game, it's useless because it's supposed bounce off , go right when hits paddle on left, it's not supposed "force" self on paddle , go left. it's kind of funny if see it:) can make sense of , give me explanation this? [code] # move ball around ...

c# - ResolutionFailedException when register a Unity interceptor -

i have code. class program { static void main(string[] args) { iunitycontainer container = new unitycontainer(); container.addnewextension<interception>(); container.registertype<itestinterception, testinterception>(new transientlifetimemanager(), new interceptor<interfaceinterceptor>(), new interceptionbehavior<policyinjectionbehavior>()); container.configure<interception>() .addpolicy("mypolicy") .addmatchingrule(new membernamematchingrule("test")) .addcallhandler<faulthandler>(); try { var tester = container.resolve<itestinterception>(); tester.test(); } catch (exception e) { console.writeline(e.gettype() + "\n\n"); } console.r...

Android emulator not rotating to landscape -

Image
when try switch orientation of emulator, emulator window rotates , orientation of emulator screen stays were. can tell me what reason this ?i have tried answers stackoverflow , nothing seem some of emulator targets 4.4 (api level 19) , 2.3 have bug. change emulator target version 4.2 or 4.3 , try change orientation. see history of bug: https://code.google.com/p/android/issues/detail?id=13189 related question: impossible rotate emulator android 4.4

java - how to get param in method post spring mvc? -

i'm using spring mvc. , can't param url when method = post. when change method get, can param. this form: <form method="post" action="http://localhost:8080/cms/customer/create_customer" id="frmregister" name ="frmregister" enctype="multipart/form-data"> <input class ="iptregister" type="text" id="txtemail" name="txtemail" value="" /> <input class ="iptregister" type="password" id="txtpassword" name="txtpassword" value="" /> <input class ="iptregister" type="text" id="txtphone" name="txtphone" value="" /> <input type="button" id="btnregister" name="btnregister" value="register" onclick="" style="cursor:pointer"/> </form> this controller: @requestmapping(value=...

backbone.js - override get method in Alloy model -

i'm trying override get: calls in alloy model, similar backbone, wrote doesn't work extendmodel: function(model) { _.extend(model.prototype, { // extended functions , properties go here get: function (attr) { if (attr=='image') { return ti.utils.base64decode(this['image']) } return this[attr]; } }); return model; }, here how overriding set , add methods hope helps you: exports.definition = { config: { adapter: { type: "properties", collection_name: "carecenter", idattribute : "carecenterid" } }, extendmodel: function(model) { _.extend(model.prototype, { idattribute : "carecenterid" // extended functions , properties go here }); ...

C: Creating a given number of variables automatically -

is possible create c-function creates automatically given number of variables? how variables named? the solution use array. example: //n number of variables int *var; var= malloc(sizeof(int) * n); variables named var[0], var[1]....var[n-1]

css - Image to pop up in front another image in 3D while hovering -

here fiddle demonstrate question fiddle css: #email { list-style: none; margin: 100px 0; height: 550px; } #email li { display: inline; float: left; -webkit-perspective: 500; -webkit-transform-style: preserve-3d; -webkit-transition-property: perspective; -webkit-transition-duration: 0.5s; -moz-perspective: 500; -moz-transform-style: preserve-3d; -moz-transition-property: perspective; -moz-transition-duration: 0.5s; } #email li:hover { -webkit-perspective: 5000; -moz-perspective: 5000; } #email li div { border: 10px solid #fcfafa; -webkit-transform: rotatey(30deg); -moz-transform: rotatey(30deg); -moz-box-shadow:0 3px 10px #888; -webkit-box-shadow:0 3px 10px #888; -webkit-transition-property: transform; -webkit-transition-duration: 0.5s; -moz-transition-property: transform; -moz-transition-duration: 0.5s; } #email li:hover div { -webkit-transform: rotatey(0deg); -moz-transform: rotatey...

c# - Doing POST to server from web-service -

hosted web service post aspx pages. the code: [webmethod] public string test() { sb.appendline("start"); try { var t = new thread(mythreadstartmethod); t.setapartmentstate(apartmentstate.sta); t.start(); t.join(); } catch (exception ex) { sb = sb.appendline(ex.tostring()); } sb.appendline("finish"); return sb.tostring(); } private void mythreadstartmethod(object obj) { try { webbrowser browser = new webbrowser(); browser.documentcompleted += browser_documentcompleted; browser.url = new uri("http://www.wikipedia.com"); while (browser.readystate != webbrowserreadystate.complete) { system.windows.forms...

vba - Run SQL on field value change using previous value and new value -

Image
i'm new vba , access , have inherited database needs improvement. i have form in access shows table editing: when labour rate value in table changed need run following query update table: update finishedproduct set labourrate = newvalue labourrate = oldvalue; (yes design of database bad.) which event can handle react labour rate changing? how can previous value of field , new value of field? something don't know: when user changes labour rate value in grid table updated immediately? you can use beforeupdate event of form , oldvalue has previous value ( value new value): private sub form_beforeupdate(cancel integer) msgbox me.txtlabourrate.oldvalue msgbox me.txtlabourrate.value end sub this happens just before record updated. cannot use afterupdate event of form because oldvalue same new value. beforeupdate happens immediately before record updated. record updated - unless cancel argument set true . there current event form happen...

node.js - Need a way to create a cookie so that node js server can access it (cross domain) -

i have node.js server socket.io . many domains communicate node server. i need way create cookie domain node.js server that, when client node.js server can access cookie. this identifying clients on reloads or page navigation in domain. i have searched lot this, couldn't find solution. have seen many people leveraging authorization event. afraid don't know when gets triggered , call backs. unsure if can sent cookie client. if need more information, please let me know.

php - Storing a hotel menu in a database -

how store restaurants menu in database. suppose have database called hotel table called restaurant . here schema. restaurant(type, name, description, pictures, address, menu) type, name, description, address strings, varchar. pictures blob type. now how store menu? restaurant has on 100 items. becomes meaningless have coloumn each menu item. how store it? can use json overcome this? if how? example of menu: pasta: 5 euros pizza: 10 euros . . . many items and not way looking for: item(restrnt id, item, price) the above work single restaurant large number of dishes. you have table of menu items, , 1 column of table foreign key match primary key in restaurant table associate menu item particular restaurant. if menu items can shared between multiple restaurants, use junction table instead (a third table 2 columns - both foreign keys, 1 on restaurant table , 1 on menu_items table.

Why is this Javascript code executed twice? -

when link clicked on site javascript code below executed, if condition true display alert dialog. when user selects ok button in alert dialog block of code executed again. so alert closes, code below executed second time , alert dialog displayed again. when used selects ok button on alert dialog second time alert dialog closed good. how can prevent code below being executed twice? $("#my-button").click(function() { var login = somevar; if(!somevar || somevar == ''){ $('.close-reveal-modal').click(); alert(mymessage); } }); check if adding click handler twice, maybe causing behavior. in case remove 1 of them.

php - MongoDB - search GridFS file contents by string -

i planning upload user's word documents in mongodb using gridfs. have implement following functionality. when admin type string , hit search in administration app, have list word documents contents contain search string. have search across user's documents. is there way achieve in mongodb? if not, best way achieve this? in mongodb best can binary match of search phrase against contents in gridfs, in word documents not find phrase it's compressed. i think better off using dedicated search solution such solr. solr allows extract text word documents , allows search sort of phrase in quite complete search language. have @ http://wiki.apache.org/solr/extractingrequesthandler dealing word documents f.e.

wpf - Winforms property grid high dpi ui overlap -

Image
i've got winforms property grid hosted inside windowsformshost. works wonderfully until change dpi settings in windows, or use monitor high dpi. when that, property names start overlap, seems arranges ui, , re-sizes font accommodate high dpi. strange. looks like: (note how value labels aren't "blown up" name labels?) have tried can think of that's related dpi. setting autoscalemode on propertygrid, removing property mappings host, setting usecompatibletextrendering etc... i've been browsing through .net source , there doesn't seem way set different font names vs values. i have tried reproduce in empty wpf application, have been unable so. have ideas? i've exhausted of resources , google skills no avail. thanks simon edit: incase it's relevant, set "change size of items" under control panel -> display "large - 150%". using windows 8 have seen issue on other platforms well. i got exact same problem ...

smartcard - How to send and get data using a single APDU in C++? -

i writing c++ code using winscard. noticed that, if send command scardtransmit data sent or data received, there no problem. can send data or correct response. however, when command both sends data , expects response 61xx. know error code 61xx means there xx bytes response le not correct, , checked every possible le, including returned value xx, nothing changes. example let apdu in form cla ins p1 p2 lc data le, , 61xx, send cla ins p1 p2 lc data xx, again 61xx. i checked card using java , other tools , verified there nothing card. as far understand, there single byte p3 allocated lc , le. there way responses (apart sw1sw2) datadata commands? when send command has command data , command expecting result data well, , communication made using t=0 protocol, need send 2 apdus. 1 command itself, , 1 retrieve result. 61xx not error. (successful) status word indicates have xx bytes of response can retrieve using get response ( ins=0xc0 ). here reference of command . ...

php - Symfony2 unique token generator -

i'm developing website , need way create token when form submitted mysql, needs unique, id column. for example, when submit form, inserts db form data plus token = txxxxxx or whatever, actually, format depend on stuff, think can handle myself, need way create unique token inside db... does knows way so? i've tried generate random php function generate number, check against mysql, if number exists, generate 1 until got non-used one, submit... slow, , not best way... maybe can use uniqid() , generate unique id

android - SQLite same result after update -

strange behaviour of sqlite update in contentprovider. update method: @override public int update(uri uri, contentvalues updatevalues, string whereclause, string[] wherevalues) { sqlitedatabase db = taskscontentprovider.dbhelper.getwritabledatabase(); int updatedrowscount; string finalwhere; db.begintransaction(); // perform update based on incoming uri's pattern try { switch (urimatcher.match(uri)) { case matcher_tasks: updatedrowscount = db.update(taskstable.table_name, updatevalues, whereclause, wherevalues); break; case matcher_task: string id = uri.getpathsegments().get(taskstable.task_id_path_position); finalwhere = taskstable._id + " = " + id; // if passed 'where' arg, add our 'finalwhere' if (whereclause != null) { finalwhere = finalwhere + " , " + whereclause; ...

javascript - strip content of a table -

i have static table lots of data in it. want strip out data javascript , crate xml result result. table sample: <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50">sn</td> <td width="200">item</td> <td width="500">discription</td></tr> <tr> <td>1</td> <td width="200">item 1</td> <td>this lenghty item discription</td> </tr> expected xml result created: <content> <sn>1</sn> <item>item1</item> <discription>this lenghty item discription</discription> </content> ... can please provide me simple js code use. thanks <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50"...

Problems while creating a c++ extension with cython -

i'm working on osx 10.8.4 64 bit python 2.7, cython 0.19.1 , numpy 1.6.1. i'm trying create c++ extension used python. c++ code given , wrote wrapper c++ class make using needed functions in python easier.compiling works importing extension file causes following error: traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: dlopen(./mserp.so, 2): symbol not found: __zn4mser12mserdetectorc1ejj referenced from: ./mserp.so expected in: flat namespace in ./mserp.so i tried smaller example easy c++ class function has got numpy array argument. importing , using of extension file works great! here wrapper class (maser_wrapper.cpp): #include "mser_wrapper.h" #include "mser.h" #include <iostream> namespace mser { callmser::callmser(unsigned int imagesizex,unsigned int imagesizey) { //create mserdetector mser::mserdetector* detector = new mser::mserdetect...

android - How do I get my CustomListAdapter to update on notifyDatasetChange? -

this first time building listview custom layout, in case have missed obvious please point out. the problem having cannot listview update new information after oncreate(); has been used. list static. i trying create custom listview adapter looks such: public class mainlistcustombaseadapter extends baseadapter { static arraylist<listitems> datasomething; static context cont; public mainlistcustombaseadapter (arraylist<listitems> data, context c){ datasomething = data; cont = c; } public int getcount() { // todo auto-generated method stub return datasomething.size(); } public object getitem(int position) { // todo auto-generated method stub return datasomething.get(position); } public long getitemid(int position) { // todo auto-generated method stub return position; } public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub view v = convertview; if (v == null) {...

vba - How to Import XML to MS Access with Memo Data Type? -

i'm having error while using code: application.importxml filename, acappenddata by default, creates "relevantresults" table "text" datatype. not of data imported because truncated. i'm thinking of creating table 1 of field memo data type , append xml. how should when create new table "relevantresults"? how should define table used? if access destination table exists, importxml acappenddata parameter preserves structure of table. adds xml data table, assuming data compatible table fields' data types. create relevantresults table memo data type need it, run importxml fill table.

amazon ec2 - Running HMA VPN on remote server -

i trying setup hma vpn remote server on amazon ec2 machine (ubunutu 12.04.02), ip of outgoing traffic changes. but hma script start vpn connection, ssh connection local machine server gets lost. i think problem lies vpn client locking network adapter ssh server no longer able listen same port listening earlier. please suggest might causing problem?

fedora - What is required to compile a simple gtk D application -

i'm getting started in d , following examples on dsource.org specifically one: http://www.dsource.org/projects/gtkd/wiki/codeexamples simple gtk program. as using fedora installed gtkd , gtkd-devel using yum when come compile using dmd following error: gtkbasic.d(1): error: module mainwindow in file 'gtk/mainwindow.d' cannot read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import you need pass path gtk root folder -i compiler option (same in c). pkg-config should work, dmd $(pkg-config --cflags --libs gtkd2) gtkbasic.d .

path - iOS: NSBundle object becomes invalid after folder removed and recreated -

i using following initialise bundle object in viewdidload. documentbundle = [[nsbundle alloc] initwithpath:path]; where path looks following; /users/..../library/application support/iphone simulator/6.1/applications/b69b8a03-c029-4df5-89e0-1429e73e840f/documents/downloads/documents.bundle while application running need update documents.bundle , rid of old one. remove , download latest 1 web. have confirmed bundle object points same folder it's not able contents inside bundle after replaced existing folder. if restart application latest contents! not sure what's going on here. can 1 point out wrong? following returns nil path after replaced bundle! can see required file right there terminal! nsstring *path = [documentbundle pathforresource:filename oftype:extension]; i have tried reinitialise bundle object after replacing bundle still points same memory address (printed using %p) , doesn't return content new bundle. i same result on both device , simulato...

Design Pattern - Objective-C - MVC Model View Controller -

hi read tutorials around web on mvc , read topics on here. think got concept of mvc i'm not sure of implementation. i've tried apply simple program, window have label , button. button increase counter , label shows value of it. i tried in 2 different ways. in first case ( example works ) melt view , controller. said, example works, want guys tell me if it's correct implementation mvc or it's not following right design. the second example has model view , controller 3 separated class, example doesnt work because v , c import itself, love guys tell me i'm doing wrong. first version: model, view-controller //model.h #import <foundation/foundation.h> @interface model : nsobject { int _counter; } -(void)setcounter:(int)valuecounter; -(int)getcounter; -(void)increasecounter; @end //model.m #import "model.h" @implementation model {} -(void)setcounter:(int)valuecounter { _counter = valuecounter; } -(int)getcounter { return _counter; }...

How to use custom bean class in search container in liferay -

i want show records in liferay portlet. have list of objects want display , using searchcontainer tag of liferay i.e. liferay-ui:search-container follows: <liferay-ui:search-container delta="5" emptyresultsmessage="no results found" iteratorurl="<%= portleturl %>" > <liferay-ui:search-container-results total="<%= contents.size() %>" results="<%= listutil.sublist(contents,searchcontainer.getstart(),searchcontainer.getend()) %>"> </liferay-ui:search-container-results> <liferay-ui:search-container-row modelvar="content" keyproperty="title" classname="com.liferay.portlet.documentlibrary.model.dlfileentry"> <liferay-ui:search-container-column-text name='name' property="name" orderable="<%= true %>"></liferay-ui:search-container-column-text> <liferay-ui:search-container-column-text name=...

c# - Coming from AOP based authentication in ASP.MVC to nodeJS -

when in .net world , using mvc common pattern used when wanting cross cutting concerns such logging, authentication, transaction management etc use di paired aop put attributes on methods required proxying/weaving. so may like: public class somecontroller { [authenticate] public actionresult someauthenticatedaction() {} public actionresult notauthenticatedaction() {} } so given above when someauthenticatedaction called check request authorization cookie logic around , either bomb user out 401 or something. know because has attribute on @ runtime knows hook , proxy. now in javascript land , looking @ getting same sort of functionality doing best way platform. wondering how should go doing in nodejs, there no sort of attribute paradigm in javascript without either ingraining authentication each app.* (get,post etc) call dont like, or @ application entry point proxy each action know needs authenticated, not ideal either. so there way me indicate method should hav...

html - CSS - How to remove unwanted margin between elements? -

Image
this seems common problem none of solutions found have worked me. html <html> <head> <link rel="stylesheet" href="c/lasrs.css" type="text/css" /> </head> <body> <div class="header"> <img src="i/header1.png"> </div> <div class="content"> <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. nam cursus. morbi ut mi. nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. sed eleifend nonummy diam. praesent mauris ante, elementum et, bibendum at, posuere sit amet, nibh.</p> </div> </body> </html> css body { min-width: 950px; background-color: #ffffff; color: #333333; } .header { width: 950px; height: 171px; margin: 0px auto; padding: 0px; background-color: #c...

Android Prevent Bluetooth Pairing Dialog -

i'm developing internal application uses bluetooth printing. want bluetooth pairing occur without user input. have managed working trapping android.bluetooth.device.action.pairing_request broadcast. in broadcast receiver call setpin method, , pairing works ok, bluetoothpairingdialog displayed second or two, disappears - see link below. https://github.com/android/platform_packages_apps_settings/blob/master/src/com/android/settings/bluetooth/bluetoothpairingdialog.java since broadcast non-ordered, can't call abortbroadcast() , , wondering if there other way prevent pairing dialog appearing. can hook window manager in way? i haven't been able come way without modifying sdk. if you're oem, it's easy (i'm on 4.3): in packages/apps/settings/androidmanifest.xml, comment intent filter pairing dialog: <activity android:name=".bluetooth.bluetoothpairingdialog" android:label="@string/bluetooth_pairing_request" ...

encryption - Java BouncyCastle Cast6Engine (CAST-256) encrypting -

i'm trying implement function receives string , returns encoded values of string in cast-256. following code implement following example on boncycastle official web page ( http://www.bouncycastle.org/specifications.html , point 4.1). import org.bouncycastle.crypto.bufferedblockcipher; import org.bouncycastle.crypto.cryptoexception; import org.bouncycastle.crypto.engines.cast6engine; import org.bouncycastle.crypto.paddings.paddedbufferedblockcipher; import org.bouncycastle.crypto.params.keyparameter; import org.bouncycastle.jce.provider.bouncycastleprovider; import org.bouncycastle.util.encoders.base64; public class test { static{ security.addprovider(new bouncycastleprovider()); } public static final string utf8 = "utf-8"; public static final string key = "clp4j13gada9amrsqsxgj"; public static byte[] encrypt(string inputstring) throws unsupportedencodingexception { final bufferedblockcipher cipher = new paddedbuffe...

python - Trouble with a simple query PyODBC -

i want query following: the attribute unknown hrs yes if employee works on @ least 1 project null hours, , no otherwise. and first making list, thelist containing relevant social security numbers , consequently: for in thelist: unknown_hours=process_query("select distinct count(*) works_on isnull(hours) , essn='%s'" %i) temp.append(unknown_hours) the trouble answers 1l or 0l , need them integers (for algorithm). thoughts? regards cenderze 1l long integer representation of integer value 1 : >> type(1l) <type 'long'> >>> long(1) 1l >>> int(1l) 1 convert in python: int(unknown_hours) or in database layer: select distinct cast(count(*) unsigned) works_on isnull(hours) , essn='%s'

oracle - SQL issue with parenthesis -

i'm getting error while processing query: select * example pri in ( select pri ( select pri ,sbst ,st ,count(*) cnt example sbst = 'oi' group pri ) tmp cnt = 1 , st = 'ko' ) , sbst = 'cp'; the error following: ora-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *cause: *action: error @ line: 5 column: 136 but don't think missed parenthesis. probably need group pri, sbst, st select * example pri in ( select pri ( select pri, sbst, st, count(*) cnt example sbst = 'oi' group pri, sbst, st ) tmp cnt = 1 , st = 'ko' ) , sbst = 'cp';

android - USB driver Asus Nexus 7 Windows 7 -

i have tried every suggestion on website , many others no avail. possible android development nexus 7 on windows? i have tried usb driver downloaded sdk manager, 1 asus. have tried changing usb mode ptp , still getting the same message when try install driver (manually). "windows not find driver software device" i know question has been answered, ran issue uninstalling unknown device, , updating driver manually not working (by selecting sdk/../usb_drivers folder). no matter did device manager, not drivers found/installed. hopefully helps - if have issue installing device (win7), worked me: disconnect usb device. on device, go settings -> developer options, , click revoke usb debugging authorizations. on device, go settings -> storage -> usb computer connection (available on drop down menu @ top right of screen). verify media device (mtp) checked . reconnect device, , should install without problem. if not, attempt update driver manually , ...

c# - Editing an entity that has a file - Default Model Binder Confusion -

i have model this public class filedetail { public string url { get; set; } [notmapped] public httppostedfilebase file { get; set; } public void uploadfile() { if (file != null) { try { ... url = "data:image/png;base64," + convert.tobase64string(objimagebytes); } } catch (exception ex) { } } } i have edit/create view this ... @model applicationbase.core.common.filedetail @html.textboxfor(x => x.file, new { type = "file", accept = "*" }) ... when edit action , default modal binder loads file property string, request.form {file=17382.jpg} when create action, default modal binder loads file httpfilecollectionwrapper request.form {} request.files {system.web.httpfilecollectionwrapper} allkeys: {string[1]} count: 1 why happening ? should httpfilecollectionbase when create new entity runs per...

android - Basic Phonegap Download issue -

hi have following code got tutorial. have run on device , doesn't anything. new phonegap , js can 1 please. function onbodyload(){ document.addeventlistener("deviceready", ondeviceready, false); } function downloadfile(){ window.requestfilesystem( localfilesystem.persistent, 0, function onfilesystemsuccess(filesystem) { filesystem.root.getfile( "dummy.html", {create: true, exclusive: false}, function gotfileentry(fileentry){ var spath = fileentry.fullpath.replace("sample.html",""); var filetransfer = new filetransfer(); fileentry.remove(); filetransfer.download( "http://www.webfoxers.com/devscope.pdf",func...

android - Expand Collapse ExpandableListView -

i have custom expandablelistview in tablelayout: <scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/scrollview1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dip" android:background="@drawable/back_ground"> <tablelayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchcolumns="2" > <tablerow > <edittext android:id="@+id/t_v" android:layout_width="100dip" android:layout_height="40dip" android:inputtype="text" /> <button android:id="@+id/btn_v" android:layout_width=...

Does anyone know if NSUserDefaults get uninstalled when deleting a sandboxed app in OSX? -

i'm curious how sandboxed app, handle uninstalling. , how nsuserdefaults affected it. depends how delete it. if remove /applications/theapp.app no, sandboxed app's files (including nsuserdefaults related files) in ~/library/containers/com.domain.theapp . however if use tools appzapper or appcleaner etc., doubtless remove container well. them.

__gfortran_transfer_integer_write undefined for Mac OSX.6.8 - gfortran -

i having trouble installing ancient f77 program on mac (os 10.6.8). when compile (with gfortran), following errors: undefined symbols architecture x86_64: "__gfortran_transfer_integer_write", referenced from: _abfind_ in abfind.o _binplot_ in binplot.o _binplotprep_ in binplotprep.o _blends_ in blends.o _chabund_ in chabund.o _curve_ in curve.o _damping_ in damping.o ... "__gfortran_transfer_real_write", referenced from: _abfind_ in abfind.o _abpop_ in abpop.o _binplot_ in binplot.o _binplotprep_ in binplotprep.o _blends_ in blends.o _calmod_ in calmod.o _chabund_ in chabund.o ... etcetera... ideas look?

python - Using Django, South and Sqlite during development -

i'm new python (2.7) , django (1.5) , working through django book whilst making hobby site. i'm using sqlite3 dev db, in production intend mysql. south looks great solution database schema migration management, doesn't play sqlite. i'm tempted install mysql on dev machine, wonder if there's way avoid that. i'd appreciate knowing simple, practical solution problem, if knows of one. edit: meant programmatic solution (for feel off topic). imagined there may way use django's settings.py , custom code accomplish this. no, there's no way around this. use south require complete alter table support sqlite not have . this , other small differences make developing on mysql better choice, if plan deploy mysql.

exception - How to solve java.lang.NoClassDefFoundError? -

i've tried both example in oracle's java tutorials . both compile fine, @ run-time, both come error: exception in thread "main" java.lang.noclassdeffounderror: graphics/shapes/square @ main.main(main.java:7) caused by: java.lang.classnotfoundexception: graphics.shapes.square @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) ... 1 more i think might have main.java file in wrong folder. here directory hierarchy: graphics ├ main.java ├ shapes | ├ square.java | ├ triangle.java ├ linepoint | ├ line.java | ├ point.java ├ spaceobjects | ├ cube.java | ├ rectprism...