Posts

javascript - How Keyboard events of a desktop website are simulated in mobile website using jquery? -

i have function tied keyboard arrow keys events in desktop website using jquery. $(document).keydown(function(e) { switch (e.which) { case 37: //left doit("leftside"); break; case 38: //up doit("upside"); break; case 39: //right doit("rightside"); break; case 40: //down doit("downside"); break; } } these working fine on desktop website, not on mobile website. (i know can't access arrow keys in mobile) i want corresponding functions executed in mobile website. (if user swipes left/up/right/down on mobile website) can me in this? i don't think can this, swipes swipes combination of different events (i.e. keydown, keyhold, keyup) . picking swipes via keyup , keydown events can difficult. better use plugin can explicitly detect swipes such hammer.js

c++ - How to compile including a .h file using mex in MATLAB? -

i'm trying compile piece of code download website. but there issues when compile mex function i'm using mex -i./ -l/lib convolve.cpp (.h , .cpp file in same folder,my current folder) i don't know it's correct or not. but matlab says error using mex /tmp/mex_100625252862836_11288/convolve.o: in function `internal_reduce(double*, int, int, double*, double*, int, int, int, int, int, int, int, int, double*, char*)': convolve.cpp:(.text+0xa2): undefined reference `edge_function(char*)' /tmp/mex_100625252862836_11288/convolve.o: in function `internal_expand(double*, double*, double*, int, int, int, int, int, int, int, int, double*, int, int, char*)': convolve.cpp:(.text+0xae4): undefined reference `edge_function(char*)' collect2: error: ld returned 1 exit status this .h file /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; file: convolve.h ;;; author: simoncelli ;;; description: header file convolve...

haskell - Strict Maybe in data definitions -

i have seen many talks / read blog posts should have strict fields in data avoid various performance issues, e.g.: data person = person { personname :: !text , personbirthday :: !utctime } this makes total sense me. functions operation on data lazy, composability isn't sacrificed. yet if add maybe field: data person = person { personname :: !text , personbirthday :: !utctime , personaddress :: !(maybe address) } i'm introducing lazyness data structure, after maybe control structure. can't unevaluated thunk hide behind just constructor? however, there strict maybe in strict or thru strict-base-types . according reverse dependencies ( strict , strict-base-types ) aren't used. so question: why 1 should or shouldn't use strict maybe in not-control data definitions? reasons use strict either/maybe/tuple types: if profile code , notice space leak, way plug leak strict data types regarded useful thi...

python - Creating a list of dictionaries where each dictionary contains another dictionary as values -

im writing algorithm in python plays this game. the current state of board of tiles in game dictionary in form of: { <tile_id>: { 'counters': <number of counters on tile or none>, 'player': <player id of player holds tile or none>, 'neighbours': <list of ids of neighbouring tile> }, ... } i have dictionary stores of tiles 'full' (i.e. tile has 1 less counter number of neighbours , player me) dictionary, full_tiles , in same form board dictionary above. i trying create list, chains , each element in list dictionary of full tiles neighbouring @ least 1 other full tile (i.e chain of full tiles). list of seperate chains on board. here code far: for tile_id, tile in full_tiles.items(): #iterates through full tiles current_tile = {tile_id : tile} #temporarily stores current tile if not chains: #if chain...

java - Perform action when soft keyboard is closing -

i want perform method when soft keyboard closing. tried overriding onbackpressed() method didn't work because back-button changes when soft keyboard open (below screenshot of button). hide-soft-keyboard-button i tried using onkeylistener turned out doesn't work soft keyboard. , don't know keycode of "hide-soft-keyboard-button" either... i appreciate since couldn't find solution anywhere. you use layout listener see if root layout of activity resized keyboard detecting whether softkeyboard shown or has disappeared possible workarounds , hacks, hence not recommend it. it more appropriate set focus change listener on edittext : youredittext.setonfocuschangelistener(new onfocuschangelistener() { @override public void onfocuschange(view v, boolean hasfocus) { if (hasfocus) { //got focus } else { //lost focus } } });

wordpress - Displaying Only The Excerpt In Post -

i used following place call excerpt show, showing full post:- this in function:- add_action( 'init', 'my_add_excerpts_to_pages' ); function my_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' ); also query <?php // retrieve 1 post id of 5 query_posts( 'p=1' ); // set $more 0 in order first part of post global $more; $more = 0; // loop while (have_posts()) : the_post(); the_content( 'read full post »' ); endwhile; ?> please can advise? thanks

ruby - Why does a method call need to be disambiguated when it can in principle be a constant? -

method calls can omit receiver , parentheses arguments: def foo; "foo" end foo # => "foo" in case above, foo ambiguous between method call , reference potential local variable. in absence of latter, interpreted method call. however, when method name can in principle constant name (i.e., when starts capital letter, , consists of letters), seems need disambiguation. def foo; "foo" end foo # => nameerror: uninitialized constant foo foo() # => "foo" self.foo # => "foo" why case? why method call need explicitly distinguished reference constant under absence of constant same name? the set of local variables in scope @ given point in program defined lexically , can determined statically, parse time. so, ruby knows before runtime local variables in scope , can distinguish between message send , local variable dereference. constants looked first lexically, via inheritance, i.e. dynamically. not known constan...