Posts

Showing posts from January, 2012

javascript - 2D top-down minimap -

Image
i'd make minimap of rpg game. is making minimap simple dividing object dimensions, velocities, , coordinates large want minimap? for example below... have size of 1000x1000px, canvas (viewport) of 500x500px, player located in center of viewport... if wanted minimap half size of actual world, do: player/viewport x,y velocity/2 player/viewport x,y coordinates/2 canvas, world, , objects' width , height divided 2 etc... that way rendering of minimap on world , velocities scaled accurately? missing anything? thanks! edit : this? function minimap() { $(".minimapholder").show(); $("#mini_map").text("hide minimap"); var minicanvas = document.getelementbyid("minimap"); ministage = new createjs.stage("minimap"); minicam = new createjs.shape(); minicam.graphics.beginstroke("white").drawroundrect(0, 0, 100, 40, 5); //blip representation of player player_blip = new createjs.shape(); ...

c# - How to pass data fromC# to Microsoft excel? -

hi looking program sends data c# windows form microsoft excel , plot these data in x-y line graph! excel.application xlapp; excel.workbook xlworkbook; excel.worksheet xlworksheet; object misvalue = system.reflection.missing.value; xlapp = new excel.application(); xlworkbook = xlapp.workbooks.add(misvalue); xlworksheet = (excel.worksheet)xlworkbook.worksheets.get_item(1); double t2 = 20; int t1 = 10; int i, j; double []s= new double[10]; (i = 0; <= t1; i++) { (j = 0; j <= t2; j++) { xlworksheet.cells[(i+1), (j+1)] = s[(j / 2)]; excel.range chartrange; excel.chartobjects xlcharts = (excel.chartobjects)xlworksheet.chartobjects(type.missing); excel.chartobject mychart = (excel.chartobject)xlcharts.add(100, 80, 300, 250); excel.chart chartpage = mychart.chart; chartrange = xlworksheet.get_range("a1", "z10"); j += 1; ...

javascript - highchart dynamically data display using xmlhttp -

i have made changes previous script, not sure if ok make changes here... anyway trying on clicking respective link, want load "highchart line graph", users dont have leave page. my main.php body has user2 -- <a href="#" onclick = "showgraph(2)"><img src="go.png"></a><br> user3 -- <a href="#" onclick = "showgraph(3)"><img src="go.png"></a> <script src="js/highcharts.js"></script> <div id="container"></div> head section contains [ i have made new edits in javascript, compared last one ] <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script> function showgraph(keyid,serid){ $.ajax({ type: "get", url: "new_graph.php", data: "id="+keyid+"...

javascript - Formatting search results displayed in a div -

i advice on formatting div tags. currently div tag in codes display results performed in function: document.getelementbyid("searchresults").innerhtml = searchhtml; and searchresults displayed in div. <div id="searchresults"></div> currently outputs displayed stacked horizontally. it looks kind messy difficult differentiate each output. i know there way format each of output. example each of outputs in container of own? and can each of container can personalized more? for each result following: // create div var resultdiv = document.createelement('div'); resultdiv.innerhtml = result; resultdiv.classname = "resultcontainer"; // add appropriate css // append result container document.getelementbyid('searchresults').appendchild(resultdiv);

structure - NServiceBus, NHibernate and Multitenancy -

we're using nservicebus perform document processing number of tenants. each tenant has own database , we're using nhibernate data access. in web application we're using our ioc tool (structuremap) handle session management. maintain session factory each tenant. we're able identify tenant httpcontext . when kick off document processing using nservicebus have access tenant identifier. need tenant id available throughout processing of document (we have 2 sagas , fire off number of events). we need create nhibernate sessionfactory each tenant need way of obtaining tenant id when configure structuremap. i've seen few posts suggesting use message header store tenant identifier unsure how to: set message header when first submit document (sending submitdocumentcommand ) reference header when configure structuremap access header within our sagas/handlers ensure header flows 1 message next. when send submitdocumentcommand handled documentsubmissionsaga ....

python - Flask-Admin: UnicodeDecodeError: 'ascii' codec can't decode byte -

i'm trying build back-end interface application flask-admin. when try access form create new entry get: unicodedecodeerror: 'ascii' codec can't decode byte 0xc3 in position 13: ordinal not in range(128) going through stack trace, problem items in table contain non-ascii characters. how can solve issue? thanks! in general, error solved forcing string array unicode unicode.encode() method . from python wiki page on subject >>> u"a".encode("utf-8") 'a' >>> u"\u0411".encode("utf-8") '\xd0\x91' >>> "a".encode("utf-8") # unexpected argument type. 'a' >>> "\xd0\x91".encode("utf-8") # unexpected argument type. traceback (most recent call last): file "<stdin>", line 1, in <module> unicodedecodeerror: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in ran...

Force Java upper cast class -

it possible force upper cast type in java? see example. public class animal{} public class dog extends animal{} dog dog = new dog(); animal test = dog; what have: (test instanceof dog) , (test instanceof animal) return true. want: (test instanceof dog) == false , (test instanceof animal) == true there way force test animal? or way creating constructor animal passing dog? trying avoid create constructor because had complex object, lot of getters/setters. thanks. i don't know why care if object animal not dog , after all, dog animal . can apply dog should applicable animal , else there design issue. but if must determine that, call getclass() (defined object ) class object, compare animal.class . if (animal.class == test.getclass())

Limit MySQL row primarily by time and then (maybe) by number of rows -

i have mysql table stores input user data , add timestamp each form submitted. the forms submitted daily, user can decide multiple per day. i have display graph showing last 6 weeks data, or, in case 6 weeks of data not contain enough data point (40) have limit on number of points (it data points earlier dates). can in 1 query or should rely on more complicate sql or worse have rely on python/php/c++/... wathever? recap: 6 weeks of data minimum if 40 data points not available in range selected -> take last 40 regardless of timestamp limit. clarification : if number of elements in time range 60 want 60 elements. if number of element in time range 30 want last 40 elements. there many ways achieve in 1 query, doubt can done efficiently . assuming table indexed on date/time field, query should virtually instant: select count(datefield) mytable datefield >= date_sub(now(), interval 6 week); i go in 2 passes, , fire either of these 2 versions depend...

android - OpenGL ES Error to String -

is there standard getting error string glgeterror() (android , ios) , eglgeterror() (android) in opengl es 1.1 or 2.0? i'm using this: #define assertgl(x) { x; glenum __gle = glgeterror(); assert(__gle == gl_no_error); } would nice enhance provide text debugger rather having glenum manually of returned value stored in __gle . try on android: http://developer.android.com/reference/android/opengl/glu.html#gluerrorstring(int) , on ios: https://developer.apple.com/library/mac/documentation/darwin/reference/manpages/man3/gluerrorstring.3.html if don't work you, can create own mapping integer error value corresponding string - should easy since there's handful of error values. error values gl2.h , gl.h headers (they start 0x05).

c# - get pixel value greyscale image 16 bits .net -

i have ushort list pixels16 consist in pixeldata 16 bits greyscale image. then, have pícturebox shows image , function user can click anywhere in picturebox , system return pixelvalue position (see below code) this code return pixel value of given position: in mind, i'm showing value of exact pixel user clicked @ position in image, right? my logic is, if image 512x512, can go first y once finds spot, go x , pixel value of point this: int pixelposition = (512 * (y-1)) + x; am in right direction? (int y = 0; y < picbox_mpr.width; y++) { if (e.y == y) { (int x = 0; x < picbox_mpr.height; x++) { if (e.x == x) { int pixelposition = (512 * (y-1)) + x; string a= pixels16[pixelposition].tostring(); messagebox.show(a); } } } } ...

php - Regular expression stripping $ in one string but not another -

i'm trying use regular expressions add php variables external html page can email html email in phpmailer the string i'm trying replace is: <strong> %temp_pass%% </strong></p><p> <a href="http://www.unlimitedtutors.com/forgotpass.php?email=%e%%&p=%mytemppass%%"> my regex is: $hashtemppass = "$2a$10$"; $temp_pass = "'=$.hel3332lo\/'"; $body = file_get_contents('email/forgot_pass_email.html'); $forgot_pass_email = preg_replace('#[0-9a-za-z.%]temp_pass%%#',$temp_pass, $forgot_pass_email); $forgot_pass_email = preg_replace('#[0-9a-za-z.%]mytemppass%%#',"$2a$10$", $forgot_pass_email); the problem of $ , number symbols stripped out of mytemppass%%, not temp_pass%% - driving me crazy - doing wrong? fact mytemppass in url? how can include $/. in replacement? your 2 strings $hashtemppass = "$2a$10$"; $temp_pass = "'=$.hel3332lo\/'...

Anyone knows a free Drupal theme with jquery Masonry? -

i can not find free drupal theme uses jquery masonry , tried more masonry modules no effect, hope knows free drupal theme jquery masonry. you can go masonry effects bootstrap theme best responsive theme i used both themes masonry. download here : https://drupal.org/project/best_responsive https://drupal.org/project/bootstrap ‎

Jquery UI Autocomplete - how to add another value with the item? -

i using autocomplete , fetch items database. here js: $(".add").autocomplete({ source: function(req, add){ $.getjson("add.php?callback=?", req, function(data) { var suggestions = []; $.each(data, function(i, val){ suggestions.push(val.name); }); add(suggestions); }); }, messages: { noresults: '', results: function() {} } }); i sending array php there 'name' , 'id'. want able know id of selected item when user selects without going database, can't put in source without being displayed, don't want. want have inivisible id every item autocomplete finds , when user selects , submits value, can insert object in database. here php file: <?php require('connect.php'); $param = $_get["term"]; $query = mysqli_query($connection, "select ...

javascript - Uncaught Error: Google Plus response -

i writing chrome extension using google plus login button. problem authenticate instead of response throws exception : uncaught error: g`{"iss":"accounts.google.com","azp":"822768261690-d94r53ch5tsma36qvjbmt0rhfh2vcbie.apps.googleusercontent.com","at_hash":"g8ulzciki58rsz77n3f9pa","c_hash":"dchw3chfaqayaa8akuuxmw","aud":"822768261690-d94r53ch5tsma36qvjbmt0rhfh2vcbie.apps.googleusercontent.com","sub":"116366060578573041256","iat":1376935399,"exp":1376939299} i confused code precisely same in quick start application javascript. client id configured according chrome extension id. project has been untouched week. working before , strange error. has seen before ? i had issue , turned out related content-security-policy. error thrown when script attempts call eval(). added unsafe-eval header e.g.: content-security-policy: script-src...

python - Query long lists -

i query value of exponentially weighted moving average @ particular points. inefficient way follows. l list of times of events , queries has times @ want value of average. a=0.01 l = [3,7,10,20,200] y = [0]*1000 item in l: y[int(item)]=1 s = [0]*1000 in xrange(1,1000): s[i] = a*y[i-1]+(1-a)*s[i-1] queries = [23,68,103] q in queries: print s[q] outputs: 0.0355271185019 0.0226018371526 0.0158992102478 in practice l large , range of values in l huge. how can find values @ times in queries more efficiently, , without computing potentially huge lists y , s explicitly. need in pure python can use pypy. is possible solve problem in time proportional len(l) , not max(l) (assuming len(queries) < len(l) )? here code doing this: def ewma(l, queries, a=0.01): def decay(t0, x, t1, a): math import pow return pow((1-a), (t1-t0))*x assert l == sorted(l) assert queries == sorted(queries) samples = [] try: t0, x0 ...

How to get categories of a post for an Octopress plugin in class Liquid::Tag -

i have code: module jekyll class connexetag < liquid::tag def render(context) categories = get_categories(context) categories.class.name # => "array" # categories # => "category1category2" # categories.join(',') # => error ! # categories.size # => error ! end private def get_categories(context) context.environments.first["page"]["categories"] end end end it outputs array, , that's ok. when try methods on categories , size or each error: building site: source -> public liquid exception: undefined method `size' nil:nilclass in atom.xml /home/xavier/octopress/plugins/connexe_tag.rb:25:in `render' i can't apply methods on categories . tell me doing wrong here ? happily, fix simple. problem code assumes every page have array of categories. isn't case atom.xml context.environments.first["page"]["categories...

javascript - Difference between "Q" and "q" in angularjs and requirejs -

i creating single page app built on angularjs, breeze, , requirejs. in setting amd requirejs work angular , breeze, encountered issue breeze's dependency on "q". if configuration rule "q" lowercase, if there no explicit export in "shim", breeze gives error: uncaught error: unable initialize q. see https://github.com/kriskowal/q "http://localhost:1498/scripts/shared/breeze.js"breeze.js:1` when require config changes references "q" "q" (even without export), code works. know why happening? this working require config: require.config({ baseurl: '../scripts', paths: { angular: 'shared/angular', bootstrap: 'shared/ui-bootstrap', dropdowns: 'app/directives/dropdowns', employeeapp: 'app/modules/employeemodule', controllers: 'app/controllers', dates: 'app/directives/dates', jquery: 'shared/jque...

events - Simulation in java using priority queues -

i've been asked simulate events store 1 counter in java using priority queue. person being served , if arrives during time increment number of people in queue.i figured out have use comparator far seems can use comparator sorting , not queuing , de-queuing events. if using discrete event modeling perspective, use priority queue schedule sequence of events drive system. can find tutorial paper on how this, along java implementation single server queue exponential interarrival , service times, in winter simulation conference paper archives.

How to convert a number to alpha character C# -

i new c# , need know how convert number alpha character. example if variable 10 passed need convert 10 nd , on. if 0 convert uh if 02 convert ij if 10 convert nd if 45 convert yh if 48 convert ol i searched , not find looking for. for further clarification (sorry not explaining fully) i have system passing numerical value equivalent alpha value in system. working on app allows these 2 systems communicate. needing translation table of sorts allows me change numerical value equivalent alpha value. doing allow me make soap call correct parameters. i can't see logic those, i'll assume mapping external somewhere. 2 options - switch , or dictionary. string result; switch(num) { case 0: result = "uh"; break; //... case 48: result = "ol"; break; default: throw new argumentoutofrangeexception(); } console.writeline(result); or alternatively, dictionary: static readonly dictionary<int,string> map = new dictionary<in...

textures - OpenGL - Very strange artifacts.. Only happens when there is a lot of instances of the same type of object -

so basicly creating 2d game. using vbos , glsl shaders. every texture load, create vbo it, every drawable object uses texture it's elements inserted vbo. while ago trying create grid object creating lot of small boxes , positioning them next each other. in same vbo because had same texture create grid object. once got on 10 or so, started having weird artifacts. so by-passed creating 1 big drawable , repeating texture on multiple times. artifacts gone. started doing text mapping (each letter instance share same texture, text map) , have noticed when go on 6 letters artifacts start appear. have no idea why happening dont have lead. so wondering if has clue might causing problem.. note: noticed in lighting system (same texture different rgb values) if put 2 lights close each other, intersect after 3 artifacts start. might caus, because text intersects due padding.. how can fix 2 textures intersect , use same texture caus artifacts? edit: ^^^ never mind removed padding , ...

regex - Advanced Regular Expressions in Javascript -

i'm developing multiple advanced expressions detects 4 things: urls, twitter usernames, hashtags , hex-colors. works if put same thing, example, 4 different hashtags, urls or colors. when put, example hashtag , different thing url hashtag disappears. here can see regularexp: var regularexp = { twitter: /(^|[,\s])@(\w{1,15})/g, color: /(^|[,\s])#((?:[a-fa-f0-9]){3}|(?:[a-fa-f0-9]){6})/g, hashtag: /(^|[,\s])#(\w{1,15})/g, url: /(^|\s)(((http(s)?:\/\/|ftp(s)?:\/\/)?([a-za-z0-9_-]+\.)?(?:[a-za-z0-9]+)(?:\.[a-z]{2,4}){1,2})(\/.*)*)/g }, replacer = { twitter: "$1<a rel='nofollow' target='_blank' href='http://twitter.com/$2'>@$2</a>", color: "$1<span class='hex-color' style='background-color:#$2 !important'>#$2</span>", hashtag: "$1<a rel='nofollow' target='_blank' href='http://twitter.com/search?q=%23$2&src=hash'>#$2</a>",...

c++ - Strange error in AVX loop vectorization -

when try unroll simplest loop avx, runtime error - segmentation fault : const int sz = 9; float *src = (float *)_mm_malloc(sz*sizeof(float), 16); float *dest = (float *)_mm_malloc(sz*sizeof(float), 16); for(int i=0; i<8; i+=8) { __m256 buffer = _mm256_load_ps(src+i); _mm256_store_ps(dest+i, buffer); } _mm_free(src); _mm_free(dest); interesting: if sz =8, or >=13, runtime not crushes. otherwise segmentation fault occurs. what's wrong? compiler - gcc 4.7. raising alignment 32 makes symptom go away. i'm not versed these intrinsics, wouldn't surprised if 32 -byte alignment required on 64-bit cpus #include <mm_malloc.h> #include <immintrin.h> int main() { const int sz = 9; float *src = (float *)_mm_malloc(sz*sizeof(float), 32); float *dest = (float *)_mm_malloc(sz*sizeof(float), 32); for(int i=0; i<8; i+=8) { __m256 buffer = _mm256_load_ps(src+i...

optimization - JavaScript Minification & Concatenation Best Practices? -

if building 10 page site , using uglifyjs minify , concatenate javascript code single file, best practice optimizing code globally across site? let's arguments sake pages have shared code , have unique code. include code single minified javascript file , include code won't used on every page? or should create additional minified javascript file every page unique code? i know best choice unique every site if there general rule of thumb applies, curious know best approach be.

html - Python regex url grab -

i having trouble figuring out how select part of html link using regex say link is: <a href="race?raceid=1234">mushroom cup</a> i have figured out how race id, cannot life of me figure out how use regular expression find 'mushroom cup'. best can 1234>mushroom cup. i'm new regular expressions , me comprehend. something re.findall('<a href="race\?raceid=(\d+)">([^<]+)</a>',html_text)

vba - Excel VB Macro compare values in entire column -

i'm new macros , i'm trying learn how write simple expressions. i'd compare values in single column see if match current day of month. for example: column h contains number corresponds random day of month. i'd know how write expression in macro if today == value in column h (in other words, if today 19th , value in column h 19) change cell text color red (or other action). so far know how select range of cells using: range("b2, c7, i8") don't know how select entire column. can tell me how write such expression? *note: i'm not talking comparing columns across sheets. need compare values in 1 column current date. thanks! to act on entire column, either of these lines work: range("a:a") columns("a") as checking if column contains specific criteria, recommend using worksheet formula countif: msgbox worksheetfunction.countif(columns("a"), day(now)) > 0 to find cells within column contain criteria, ...

Mercurial equivalent of "git pull --rebase" -

this question has answer here: hg: how rebase git's rebase 5 answers is there mercurial equivalent of git pull --rebase ? try hg pull --rebase . mecurial's pull git's fetch, , git's fetch mercurial's pull, when you're rebasing you're updating working dir either way, hg pull --rebase guy. note: because rebase alters history, it's disabled default. can turn on (no need download, have it) adding following in configuration file: [extensions] rebase = ( more info )

c++ - Random sample from a large population runs into infinite loop -

i want draw n samples relatively large population without replacement. draw random numbers , keep track of previous choices, can resample whenever drew number twice: boost::mt19937 generator; boost::uniform_int<> distribution(0, 1669 - 1); boost::variate_generator<boost::mt19937, boost::uniform_int<> > gen(generator, distribution); int n = 100; std::vector<int> idxs; while(static_cast<int>(idxs.size()) < n) { // random samples std::generate_n(std::back_inserter(idxs), n - idxs.size(), gen); // remove duplicates // keep that's not duplicates save time std::sort(idxs.begin(), idxs.end()); std::vector<int>::iterator = std::unique(idxs.begin(), idxs.end()); idxs.resize(std::distance(idxs.begin(), it)); } unfortunately, run infinite loop constants used above. i added output (that shows keeps picking same number) , stopping after 10 tries showing problem: boost::mt19937 generator; ...

Advice: Struggling with Model-View-Controller in JavaScript -

i trying better understanding of mvc. can't find content out there understand , can re-engineer better understand inner workings. i understand model data (javascript objects or something), view html , controller browser. is correct understanding? can point me simple, down , dirty example of mvc? thanks in advance helpful input. the mvc framework includes following components: models . model objects parts of application implement logic application's data domain. often, model objects retrieve , store model state in database. example, product object might retrieve information database, operate on it, , write updated information products table in sql server database.in small applications, model conceptual separation instead of physical one. example, if application reads dataset , sends view, application not have physical model layer , associated classes. in case, dataset takes on role of model object. views . views components display application's user...

php - Integer inserting as 0 instead of NULL -

when insert null mysql integer field via php prepared statement inserts 0. i have searched similar questions , have update code still having problem. in code, if text box sends empty string php; php converts null ie. $v3 = (strlen($v3)<1 ) ? null : $v3; as example, result in unit column null. the prepare statement $stmt = $mysqli->prepare("insert address ( `person`, `type`, `unit`, `street_num`, `street`, `street_type`, `suburb`, `state` ) values (?,?,?,?,?,?,?,?)")); bind parameter integer $stmt->bind_param('isiissss',$p, $add_type[$a], $unit[$a], $street_num[$a], $street_name[$a], $street_type[$a], $suburb[$a], $state[$a]); in mysql, address.unit nullable , has no default value. if insert directly table , omit value unit column; null stored. expected. i suspect bind_param function changes null 0 if datatype column specified 'i' (integer), because nulls passed varchar columns stored null. correct , if how should pass null in...

android - namespace declarations in Google V2 map fragment -

the docs can specify following xml define v2 map... <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.supportmapfragment" map:camerabearing="112.5" map:cameratargetlat="-33.796923" map:cameratargetlng="150.922433" map:cameratilt="30" map:camerazoom="13" map:maptype="normal" map:uicompass="false" map:uirotategestures="true" map:uiscrollgestures="false" map:uitiltgestures="true" map:uizoomcontrols="false" map:uizoomgestures="true"/> however when try map fragment definition, ... <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:...

Android: Resetting repeating AlarmManager from within called service -

i've set repeating alarm on service , decided it's convenient reset alarm within called service. reason service has code check if it's within user-defined schedule (time range). when it's outside time range, resets alarm start @ future time selected user. maybe i'm approaching wrong i'll put question out there , see think. an activity kicks off service creating repeating alarm: //activity calendar cal = calendar.getinstance(); intent intent = new intent(getapplicationcontext(), myservice.class); intent.setdata(uri.parse("myservice://identifier")); pendingintent pintent = pendingintent.getservice(getapplicationcontext(), 0, intent, 0); alarmmanager alarm = (alarmmanager)getsystemservice(alarm_service); alarm.setinexactrepeating(alarmmanager.rtc_wakeup, cal.gettimeinmillis(), intervalinmins*60000, pintent); the service has this: //service @override public int onstartcommand(intent intent, int flags, int startid) { uri action ...

Maps Android V2: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable -

as many following error: java.lang.noclassdeffounderror: com.google.android.gms.r$styleable when trying implement maps android v2. somehow must missing doing wrong, since it's not working. tried first copy google-play-services.lib lib folder, saw somewhere shouldn't this. then tried import addon-google_apis-google-8 project, project gives error the import com.google cannot resolved. i'm following vogella tutorial : activity: supportmapfragment fm = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map); map = fm.getmap(); //map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); marker hamburg = map.addmarker(new markeroptions().position(hamburg) .title("hamburg")); marker kiel = map.addmarker(new markeroptions() .position(kiel) .title("kiel") .snippet("kiel co...

html email - PHP variable and styling -

i have code here trying style php variable of $first css, isnt right, hence reason here. i want style entire message , include logo, and/or background color, when email sent out it's "html email", know nothing php, guess i'm learning bit bit. here code: -------> $user = "$email"; $usersubject = "thank subscribing"; $userheaders = "from: subscriptions@3elementsreview.com\n"; $userheaders .= "content-type: text/html\r\n"; $usermessage = "welcome <span style='color:#ff6000; font-size:1.25em; font- weight:bold;>$first</span>, we're glad you've decided subscribe our email list! there's lot of great things happening @ 3elements can't wait show you. stay tuned notifications submission periods, issue release dates, contests, , other news. also, sure on facebook , follow on twitter! sincerely, 3elements team www.3elementsreview.com facebook.com/3elementsreview @3elementsreview...

c# - Entity Framework returning partially empty dataset -

i have dbcontext query return model contains total count of items , ienumerable type represents subset of items. have 3 environments: localhost, development, , test. using same version of code, development , localhost return complete dataset count , list of items. test returns proper count empty list of items. codeset same between environments. have pointed environments @ same database isolate issues might exist in db. query looks like: var rawitems = context.entity.where(x => x.id == id).orderby(x => x.id); totalcount = rawitems.count(); return rawitems.skip(0).take(25).select(x => x.toexternalmodel()) toexternalmodel transformation method takes object , transforms different model. there no exceptions thrown code. removed try/catches make sure. i think environment problem don't know else possibly be. the problem bad foreign key definition in entity framework schema. i'm still not sure why environments created working version of query , 1 env...

ajax - PHP post method apparently not working -

latest edit: turns out that, in formprocessing.php, isset($_post['submit1']) false (where 'submit1' name of submit button; did not have name). seen in code below, did not test originally. it explain lot. remaining question why isset($_post['submit1']) false. note: question has been edited reflect more recent insights. as php beginner, i’m experimenting posting forms server, , not work. in likelyhood i’m overlooking simple, don’t see it. i have 2 files: ‘form.php’ , ‘formprocessing.php’, both located in same folder. have included full code below, first explanation. file ‘form.php’ contains form itself, including ‘post’ method. file ‘formprocessing.php’ destination, speak, of ‘post’ method, i.e. “action = formprocessing.php”. the idea formprocessing should take place without 'formprocessing.php' loading or 'form.php' reloading (hence "event.preventdefault();" in form.php). i’m aware posting ‘form.php’ itself, want go 2 se...

php - I want to get value from fields loop .How can I do? -

i'm using joomla , have begun develop web app, want values form fields. use $_post page didn't work. this default.php >>> <?php defined('_jexec') or die; jhtml::_('behavior.keepalive'); jhtml::_('behavior.tooltip'); jhtml::_('behavior.formvalidation'); ?> <div class="item" <?php echo $this->pageclass_sfx?>"> <?php if ($this->params->get('show_page_heading')) : ?> <h1><?php echo $this->escape($this->params->get('page_heading')); ?></h1> <?php endif; ?> <form id="add-item" action="<?php echo jroute::_('index.php?option=com_stationery&task=item.save'); ?>" method="post" class="form-validate" enctype="multipart/form-data"> <?php foreach ($this->form->getfieldsets() $fieldset): // iterate through form fieldsets , display each one.?> <?php $...

svn - check-in multiple files 200+ in one shot -

i'm trying figure out how commit large number of files (it 250 in case) in 1 shot, i.e. don't want break down in multiple commits. far i've tried --targets option, or just svn commit `cat mylist` in both cases seems svn picks last 100 or files , ignores rest. intended behaviour? usual way commit a lot of files? thanks. svn ci should it. 'ignoring' files sounds files have not yet been added via svn add , must happen before commit.

jquery - friendly url causes ajax to not get the correct url -

i converted url user friendly, problem is, caused ajax not work properly: instead of returning json, responds text/html; charset=utf-8 , idea? localhost/home/ticket?tab=0 to localhost/home/ticket/0 jquery datatable self.$('#tblticket').datatable({ "bdestroy": true, "bserverside": true, "sajaxsource": '/home/ticket/ajaxhandler', "fnserverparams": function (aodata){ aodata.push( { "name": "sstatus", "value": status } ); }, routers routes.maproute( name: "ticketroute", url: "ticket/{tab}", defaults: new { controller = "ticket", action = "index", tab = urlparameter.optional } ); update 1 if change router this, works, url localhost/home/ticket/index/0 . router interferes ajax call, idea? want url localhost/home/ticket/0 , still able ajax call, have no idea, can done? routes.maproute( name: ...

ruby - Automatically create instance of a model every day with rails -

i writing app 2 models, user , daily. each user has_many dailies. trying create daily report each user every day @ midnight. how do in rails? in backbone, find time between , midnight, set timeout amount of time, , create new model, , call function recursively. looked @ rails: reset model attribute @ specific time each day , saw suggestion use whenever , cron, wasn't sure if there better way accomplish trying do. a temporary solution came create new daily when user visits home page if current user doesn't have daily today's date. has problem of creating report day if user visits homepage on day. if user navigates around homepage, report won't created, , think it's intrusive solution put check in every action. there way in rails automate task? edit: idea had put after_create daily class, , use same solution backbone solution. optimal way accomplish this? you should check out gem whenever . it allows define tasks in readable dsl in config/schedule....

Suggestions for plotting heat map of 17K x 1K data points in D3.js -

using svg rectangle each data point extremely slow. please suggest workaround. for data svg not optimal. use canvas instead , information pixel manipulation this: what's best way set single pixel in html5 canvas?

wordpress - add_submenu_page doesn't display submenu if menu slug is the same as in top menu -

i'm trying create top menu , submenu, prevent duplicating top menu in submenu, i'm setting submenu menu_slug same in top menu. why submenu not displayed @ in case? add_action("admin_menu", "setup_theme_admin_menus"); function setup_theme_admin_menus() { add_menu_page('theme settings', 'example theme', 'manage_options', 'tut_theme_settings', 'theme_settings_page'); add_submenu_page('tut_theme_settings', 'front page elements', 'front page', 'manage_options', 'tut_theme_settings', 'theme_front_page_settings'); } // handler top level menu function theme_settings_page() { } function theme_front_page_settings() { echo "some text of submenu page"; } that's default behavior, see $menu_slug documentation add_submenu_page : if want not duplicate parent menu item, need se...

javascript - select data from sqlite in angular. Data is nor rendered -

i'm building mobile application phonegap , angular.js. i'm using sqlite save local data. , problem can't render asynchronous data i'm getting sqlite. problem data not rendered i'have tried $apply method doesn't works. here code below function projectlistctrl($scope) { $scope.test = function(){ db.transaction(querydb, errorcb); var test1 = function(db_result){ // $scope.projects = db_result; // $scope.$apply(); $scope.projects = db_result; $scope.$apply(function(){ $scope.projects = db_result; }); console.log($scope.projects) } var make_result = function (tx, results, $scope) { querysuccess(tx, results, $scope,test1 ); }; function querysuccess(tx, results, $scope, callback) { var len = results.rows.length; var db_result = []; (var i=0; i<len; i++){ db_resul...

android - ViewPager behaves in an unexpected way -

my goal implement guide/how-to-use-app activity in app, users can flip between predefined set of views. so, decided use viewpager . this how did in guideactivity : mpager = (viewpager) findviewbyid(r.id.pager); madapter = new guideadapter(getbasecontext()); mpager.setadapter(madapter); and implementation of pageradapter : class guideadapter extends pageradapter { private context context; protected static final int[] slides = new int[] { r.drawable.page1, r.drawable.page2, r.drawable.page3 }; public guideadapter(context context) { this.context = context; } @override public view instantiateitem(viewgroup container, int position) { imageview image = new imageview(container.getcontext()); image.setimageresource(slides[position]); container.addview(image, layoutparams.wrap_content, layoutparams.wrap_content); return image; } @override public void destroyitem(viewgroup colle...

MYSQL Access denied for user 'root'@'localhost' -

i did following steps use mysql in ubuntu: sudo aptitude install php5-mysql mysql-server sudo service mysql stop sudo mysqld_safe --skip-grant-tables & sudo mysql -u root mysql change root password: mysql> update mysql.user set password=password('securepassword') user='root'; mysql> flush privileges; mysql> exit modify /etc/mysql/my.cnf: [client] user=root password=securepassword [mysqld] ... default-time-zone = '+0:00' then: sudo service mysql start mysql -u root mysql> show grants root@localhost +--------------------------------------------------------------------------------------------------+ | grants root@localhost | +--------------------------------------------------------------------------------------------------+ | grant usage on *.* 'root'@'localhost' identified password '[here securepassword]' | +------------------------------------------------------------------------------------------------...

javascript - Google Maps LatLng returning (NaN,NaN) -

i obtaining clients geographic coordinates following code: loc={} if (navigator.geolocation) { navigator.geolocation.getcurrentposition(function(position){ loc.lat = position.coords.latitude; loc.lng = position.coords.longitude; }); } i trying turn google map coordinate following code var clientlocation = new google.maps.latlng(loc.lat, loc.lng); this returning (nan,nan) can suggest may doing wrong? it's because getcurrentposition() asynchronous you're expecting synchronous response. getcurrentposition() takes function argument, i'm assuming call when has finished running. function callback updates loc object. the problem you're expecting loc updated before getcurrentposition has finished running. what should instead let function call latlng creation, this: var loc={} // don't forget var declaration, or might mess global scope if (navigator.geolocation) { ...

jquery - Dynamic Page Replacing Content -

i have used example create dynamic page effect. here demo . want make page transition slide left right instead of fade in , fade out. how slide effect?

ios6 - IOS 6 Orientation -

i working on project , facing problem. problem making project 5.0 , above, project in portrait view 1 view has both view (landscape , portrait) using navigationcontroller custom class , check orientations in custom navigation class ` - (nsuinteger)supportedinterfaceorientations { int interfaceorientation = 0; if (self.viewcontrollers.count > 0) { id viewcontroller; (viewcontroller in self.viewcontrollers) { if ([viewcontroller iskindofclass:([calenderviewcontroller class])]) { interfaceorientation = uiinterfaceorientationmaskall; } else { interfaceorientation = uiinterfaceorientationmaskportrait; } } } return interfaceorientation; }` calenderviewcontroller view supported both view code works fine popview when pop view calenderviewcontroller, works fine when push new view controller on calenderviewcontroller has portrait view new viewcontroller remains in landscape, whereas should...

jquery - how to set up priority for functions in javascript -

my team developing web application, particular element have click event defined in 2 js files. $("#manage_teams_register_btn").live("click",function(){ // codes here }) now appending html elements in 1 js file , in other getting data db , appending it. possible set priority in these live click functions 1 gets called ahead of other!? i cant use solutions putting contents of 1 live click function , calling live click defined in other js or other solutions, need put priority inside these live click functions. there way can this?? this model might helpful $("#manage_teams_register_btn").live("click",function(){ function1(); function2(); }); function function1(){ } function function2(){ } maintain 1 click event otherwise horriblly kills readability od code.

How to run intern to test a dojo application running with node.js ? -

i'm trying use intern test dojo application running under node.js my intern.js configuration file like: define({ loader: { packages: [ { name: 'elenajs', location: 'lib' }, { name: 'tests', location: 'tests' } ], map: { 'elenajs': { dojo: 'node_modules/dojo' }, 'tests': { dojo: 'node_modules/dojo' } } }, suites: [ 'tests/all' ]}); when try run test node node_modules/intern/client.js config=tests/intern , error: error: node plugin failed load because environment not node.js . normally have configured dojo dojoconfig = { ... hascache: { "host-node": 1, // ensure "force" loader node.js mode "dom": 0 // ensure none of code assumes have dom }, ... }; how can solve intern? the issue experienci...

oauth 2.0 - Scope to get email address alone? -

Image
i use https://www.googleapis.com/auth/userinfo.email scope email address of authenticated user. while authenticating, google prompts user: the app to: know on google+ (for icon says: this app requesting permission associate public google profile ) view email address i don't want user's google+ related information. using oauth2 authentication method . authsub request authentication requires email address access. how can access user's email address alone? if using google+ sign-in , https://www.googleapis.com/auth/plus.login scope automatically included, why seeing portion of permission dialog. if not need enhanced features come along google+ sign-in feature, you'd want standard oauth flow. see google oauth scenarios solution might fit needs can ask email scope.

html - dynamically creating a table and adding cells to the table through a function with Javascript -

i wondering how create function loop creates new cells / rows other loop call upon. function should return newrow should specified amount of cells. idea html code displays 3 images per row, if there 2 images needs 2 cells. first if / else statement. here code far.. var cells = document.getelementsbytagname('td'); var cell = '<td>' + cells[0].innerhtml + '</td>'; //console.log(cell); document.getelementbyid('searchbtn').onclick = search; //specified 3 per row var numperrow = 3; //gets number form text input var num = document.getelementbyid("searchtxt").value; function search(){ //var num = 4; console.log(num); //loop once per row var htmlstr = ''; (var = 0; < num; = + numperrow){ //htmlstr += '<tr>' + cell + cell + cell + '</tr>; if (num - >= numperrow) { //displays new row of 3 htmlstr += newrow(numperrow); }else { //less 3 display ...

android - Eclipse wont recognize my tablet when I try to test my app? -

recently bought new android tablet (a no-name chinese tablet), , i'd test application i'm developing on it. however, when try run through eclipse, won't recognize tablet (the debugging mode enabled on tablet). when have select device dialog see same thing, solution did not help, eclipse still cannot see tablet properly: http://i.imgur.com/jg7pf68.png using ubuntu 12.04 ment question: question appreciated. also, looked @ numerous guides, did not help.

validation - How to configure custom message interpolation with Hibernate? -

i write custom message interpolation. want jpa use custom message interpolation. here http://docs.jboss.org/hibernate/validator/4.2/reference/en-us/html/validator-bootstrapping.html#section-message-interpolator found following description: configuration<?> configuration = validation.bydefaultprovider().configure(); validatorfactory factory = configuration .messageinterpolator(new valueformattermessageinterpolator(configuration.getdefaultmessageinterpolator())) .buildvalidatorfactory(); validator validator = factory.getvalidator(); but should write such code? in web.xml in init-servlet? can provide such code in persistance.xml? p.s. copy&paste code. in case line valueformattermessageinterpolator(configuration.getdefaultmessageinterpolator())) will change on this custommessageinterpolator(configuration.getdefaultmessageinterpolator())) see how dynamically resolve message parameters hibernate validator? the jsr-303 bean validation framework p...