Posts

Showing posts from June, 2011

php - How to check if the controller and action actually exist? -

in app record page views in database, in appcontroller: $this->link->save(array( 'controller' => $this->request->params['controller'], 'action' => $this->request->params['action'], 'var1' => $this->request->params['pass'][0], 'var2' => $this->request->params['pass'][1] )); which works fine, of urls people (or bots) type in 404s. how can check see if these links real or not. lots of requests previous websites on same domain, requests /images etc cake thinks controller. i don't mind if check happens before entering database or after being retrieved database in view. thanks! haven't tried myself, can try calling router::parse() you provide full url, , return value cake's route array can see values of controller, action etc.

c++ - LoadLibrary call System Error wpcap.dll -

i'm trying load dll i've made dynamically in project. when go load library following error message: "the program can't start because wpcap.dll missing computer. try reinstalling program fix problem." i've searched , haven't found solution works me. replaced wpcap.dll file packet.dll file said missing , still gave me error. if me out appreciate it. thanks. there dependency walker (http://www.dependencywalker.com/) can use find related dependencies of program. can use search missing dependencies. use on wpcap.dll. using on .exe not dependency walker doesn't find dependencies using loadlibrary call.

html - Creating Dynamically Sized DIV Boxes with Static Headers -

Image
i'm working on type of dashboard contains div's of various sizes. height , width percentage based , content of each div box dynamic. need create nice headers describe contents of box. the header inside of box. causes lots of problems when overflow involved , makes spacing inner content annoying. is there easier way sized headers inside of div or easier put them on top of boxes little hats. this extremely close want header scrolls content! that's terrible. create div title header this want, widget contraption describes it's own contents. here's fiddle getting quite close http://jsfiddle.net/exrxr/1019/ but position absolute overrides many things... i put demo prior question being edited include link demo, first iteration, though after looking @ linked demo seems mark-up close: <div class="dashwrap"> <h2>header</h2> <div class="dashcontent"> <p><!-- content --...

mysql - mysqlimport reports Error: 29, File '/tmp/newTable.txt' not found (Errcode: 13), when using table: newTable -

for while not have been trying import tab separated text file mysql database. keep getting error. a few forums advised should change mode of file , folder 777. did, still same error. error: 29, file '/tmp/vehiclemake.txt' not found (errcode: 13), when using table: vehiclemake sorry trouble, used --local option , worked.. magic!!!

Element sessionID is undefined Coldfusion -

i have test server , live server of coldfusion. in both have hosted same project , using value of sessionid in both test , live server session. in live server ,surprisingly saying sessionid undefined in session. have enabled option "enable j2ee session variable" in cfadmin , error resolved. have analyzed test server , found sessionid present in session without checking option "enable j2ee session variable".. how can possible? you check if scope cascading (scope precedence) turned off in coldfusion admin panel. 'scopes'. depends on cfml-engine running find it. or scope variable, like: #session.sessionid# i recommend scope variables, because: - scope precendence slow down performance server must cycle through different possible scopes. - code more readable if scope variables correctly , make less mistakes

database - Error connecting to Redis Server from Node.js on Amazon AWS EC2 server -

i trying run node.js server , redis server on amazon aws ec2 micro instance . i have installed redis server , redis-server command runs fine . i use ' forever ' keep redis-server running . , works fine . but when start node server , fails connect redis-server . it gives following error - error error: redis connection 127.0.0.1:6379 failed - connect econnrefused doing 'forever list' shows redis server running fine . info: forever processes running data: uid command script forever pid logfile uptime data: [0] _pxw node app.js 26670 26671 /home/ubuntu/.forever/_pxw.log 0:0:0:13.463 data: [1] ylt1 node redis-server 25013 26681 i have verified when redis-server starts , starts @ 6379 port . can me explain why error happening , how fix ? i use following code connect redis . have client libraries installed redis . var redis...

Android alarms, service as not been called -

in activity: intent myintent = new intent(this, myalarmservice.class); pendingintent = pendingintent.getservice(this, 0, myintent, 0); alarmmanager alarmmanager = (alarmmanager)getsystemservice(alarm_service); calendar calendar = calendar.getinstance(); calendar.settimeinmillis(system.currenttimemillis()); calendar.add(calendar.second, 10); alarmmanager.set(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), pendingintent); toast.maketext(this, "start alarm", toast.length_long).show(); the class called: public class myalarmservice extends service { @override public void oncreate() { // todo auto-generated method stub toast.maketext(this, "myalarmservice.oncreate()", toast.length_long).show(); } @override public ibinder onbind(intent intent) { // todo auto-generated method stub toast.maketext(this, "myalarmservice.onbind()", toast.length_long).show(); return null; } @overri...

Writing and submitting a form view with Ember.js -

i'm working on proof of concept demo , need write form view let me add items content array. i'm loading view externally compiling using handlers. i've added submit method , used {{action}} binding each time click submit button reloads page. missing? // template <form> <div> <label for="client">client name</label> <input type="text" id="client" placeholder="add client name" /> </div> <div> <button {{action "addclientsubmit" target="pm.addclientview"}}>add client</button> </div> <div> <a href="#" {{action "closewindow" target="pm"}}>close</a> </div> </form> // view code pm.addclientview = ember.view.create({ templatename: 'addclient', classnames: 'overlay', addclientsubmit: function(e){ e.preventd...

HTML Select not working in Android -

i have super basic html select form field - <select> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> </select> but reason when tap on them nothing happens. happening in webview on android 2.2.2 strange thing work... do have user-scalable=0; in meta tag? if so, try user-scalable=yes;

How to authenticate with facebook account in Plone -

i'm searching existing plone add-on allows facebook users authenticate in plone - version 4.x. there plonesocial.auth.rpx it's full of bugs , doesn't work in plone 4. https://github.com/redturtle/pas.plugins.velruse this plone plugin let enable authentication of social networks users in plone sites, using velruse. velruse pyramid application defined: velruse set of authentication routines provide unified way have website user authenticate variety of different identity providers and/or variety of different authentication schemes. it similar in ways janrain engage exception of being open-source, locally installable, , pluggable custom identity providers , authentication schemes. —from velruse documentation

jquery - qTip doesn't show content when used in each loop -

i trying create tooltips contents of div element using qtip + jquery. if try define tooltip static content, seems working fine. when try use them inside loop , contents of div element , try display tooltip, nothing shows up. have following code inside document ready function. display property set none class 'tooltip' $.each($(".tooltip"), function (i, val) { var thecontent = $(val).html(); $(val).qtip({ content: $(val).html, style: { width: 200, background: '#ebf1ff', color: 'black', textalign: 'center', border: { width: 1, radius: 4, color: '#aaccee' }, tip: 'bottomleft', name: 'dark' } ...

ruby on rails - Importing data from one table to another through a form -

i have application trying create check_in page list of checked_in persons listed. pulling data, such name, phone number, address original table checked_in table. in view have form follows: <%= form_for @check_in, :url => {:controller => 'check_ins', :action => 'create' } |f| %> <% @account.children.each |child| %> <%= f.check_box :child_id, :checked => 'checked' %> <%= image_tag child.photo.url(:thumb) %> <span class="name"><%= child.first %> <%= child.last %></span><br/> <% end %> the listed child.first , child.last comes table named children. in checked_in table columns labeled child_first, child_last. how transfer results of form table? using sql database.

Calculating margin and bias for SVM's -

Image
i apologise newbishness of question in advance stuck. trying solve question, i can parts i)-1v) stuck on v. know calculate margin y, do y=2/||w|| and know w normal hyperplane, don't know how calculate it. always w=[1;1] ? similarly, bias, w^t * x + b = 0 how find value x data points? thank help. consider building svm on (very little) data set shown in picture example this, maximum margin weight vector parallel shortest line connecting points of 2 classes, is, line between , , giving weight vector of . optimal decision surface orthogonal line , intersects @ halfway point. therefore, passes through . so, svm decision boundary is: working algebraically, standard constraint , seek minimize . happens when constraint satisfied equality 2 support vectors. further know solution . have that: therefore a=2/5 , b=-11/5, , . optimal hyperplane given , b= -11/5 . margin boundary this answer can confirmed geometrically examining picture.

javascript - Why won't function output into this jQuery selector? -

i'm hoping silly i've done. got function unigref near bottom, (i believe) outputs string. however, when call function build jquery selector, can't work properly. know else works because when use static string radio button selected. here's jsfiddle/9edxx . please help. var checkcount = 0; var maxchecks = 2; $(document).ready(function() { $("#test").click(function() { alert($(':checked').length); }); $(':checkbox[name=checkbox]').change(function() { checkcount = $(':checkbox:checked').length; if (checkcount >= maxchecks) { $(':checkbox[name=checkbox]').not(':checked').attr('disabled', true); $(":radio[value="+uniqref()+"]").prop('checked', true); } else { $(':checkbox[name=checkbox]:disabled').attr('disabled', false); } if (this.checked) { $("td.label").append("<label>" + t...

javascript - Validating e-mail address -

i trying validate e-mail address using javascript. problem if statements aren't executing correctly. if delete 'else statement' code runs correnctly , page not load errors. if include 'else statement' else statement never executes , status bar says page loads errors. wondering if can find errors unable pick up? <h4>example 4:</h4> <div style="border:3px dashed #aaa; width:200px;"> <div id="text">e-mail: <input id="email" onblur="verifyemail()"/></div> <div id="verification" > </div> </div> <script type="text/javascript"> function verifyemail(){ var email = document.getelementbyid("email").value; var atpos=0; var dotpos=0; atpos = email.indexof("@"); dotpos = email.lastindexof("."); if(atpos<=3 || dotpos<atpos+2 || dotpos+2>=email.length){ document.getelementbyi...

database design - How many records can I store in 5 MB of PostgreSQL on Heroku? -

i'm going store records in single table 2 fields: id -> 4 characters password_hash -> 64 characters how many records 1 above able store in 5mb postgresql on heroku? p.s.: given single table x columns , length of y - how can calculate space take in database? disk space occupied calculating space on disk not trivial. have take account: the overhead per table (small, entries in system catalog, may not affect on heroku). the overhead per row (heaptupleheader) , per data page (pageheaderdata). details page layout in manual . space lost data type alignment . space null bitmap . free tables of 8 columns or less, irrelevant case. dead rows after update / delete . size of index(es) . you'll have primary key, right? index size similar of table indexed columns , less overhead. the actual space requirement of data, depending on respective data types . details character types (incl. fixed length types) in manual : the storage requirement short ...

jquery - SlideToggle in wordpress - only one open at a time? -

i hope can help! i've found numerous posts on slidetoggle , how show 1 div @ time, don't know how implement menu in wordpress theme bought. here theme: http://themes.themegoods.com/rhea_wp (i've hacked menu doesn't annoying fade thing (and music). see how menus stay open when click them? below code menu. possible edit code make show 1 submenu @ time? i'd others close when click on main link. maybe don't need use slidetoggle? perhaps slideup , slidedown? or else? i'm new , need fix client! appreciate help! $j.fn.setnav = function(){ $j('#main_menu li ul').css({display: 'none'}); $j( 'ul#main_menu > li:has( ul li.current-menu-item )' ).each(function() { $j(this).find('ul.sub-menu').css({overflow:'visible', height:'auto', display: 'block'}); }); $j('ul#main_menu > li:has( ul.sub-menu )').click(function() { var $jsublist = jquery(this).find('ul:first'); $jsubl...

javascript - jquery mobile+ filration list search creteria -

on homepage, there list of several criteria selected (budget max, budget min...), , wish sends back, clicking button "research", list of links corresponding answer of research in page using jquery mobile (javascript). please, have example how can please help here example of paged search results using jquery mobile . an easier method use filter bar , wouldn't give advanced search options looking for.

c++ - WTSConnectSession -

i trying use function connect specific user session. have tried , function fails either error_access_denied 5 (0x5) access denied or error_ctx_winstation_access_denied 7045 (0x1b85) requested session access denied. hard-coding session id in , password wtsconnectsession(2, 1 ,text("test1"),false); is there better way start user session use function. trying implement fast user switching , last piece in puzzle logon user session. thank you. are sure connecting username (specified targetlogonid parameter) in "remote desktop users" group? you can check using net localgroup "remote desktop users" another option enable security auditing , analyzing security event log. tells exact root cause of error_ctx_winstation_access_denied

google app engine - Consuming tasks from GAE Task Queue -

i use task queue app in gae . know (according task queue documentation , api), can add tasks push queue , , being consumed automatically app. in pull queue , can add tasks, , tasks being consumed automatically according scaling properties handle. i know whether there ability consume tasks task queue ( push or pull queues ), when want calling consume-like method ? thanks i think misunderstood how push , pull task queues works. in both queues add tasks queue, while in push queue system dequeue task , assign apropriate handler in pull queue need dequeue task(s) using lease_tasks , handle task.

javascript - PDF Viewer on Sencha Touch 2 -

i have got weird situation on sencha touch2 . i have issue read , display pdf file in framework. read on sencha forum/google .etc , didn't find real solution. i have json object feed pdf's url (pdfs not locally) . what tried this: <embed type="application/pdf" width="100%" height="100%" src="file.pdf" /> i have have scroll issue, t shows first page, because sencha has got own scroll panel ... etc <object data="yourfile.pdf" type="application/x-pdf" width="100%" height="100%" </object> it has same thing, scrolling issue <iframe src="http://docs.google.com/viewer?url='+encodeuri+'&embedded=true" width="100%" height="780" style="border: none;"></iframe> i kind of liked google idea, nor reason did not worked on ipad, think google requires logged in, in case want read view pdf ps: t...

html5 - Is it possible to make a PhoneGap app for iOS without Mac? -

so have html 5 app , have access apple developer center (ios dev center more exact). question can use without buying (lending) mac? meaning, can create/download developer certificate , provisioning profile windows or linux? according article, no longer need mac? https://web.archive.org/web/20150303180446/http://community.phonegap.com/nitobi/topics/detailed_guide_for_setting_up_building_ios_apps_without_a_mac edit: link updated

Importing a folder-tree of html files into mediawiki? -

let's have tree of several nested folders , within each of them there several simple html files. is there way import structure media-wiki website? (or alternatively, add these html files wiki-like feature)? i not sure tools can such task or ask it. thanks. you need html wikitext converter (there several, e. g. html::wikiconverter perl module, or this web service , or this xsl file ) , bot framework automate (the mature 1 pywikipediabot ).

c - Fastest way to copy an array - Does it have something questionable? -

when working arrays of same length, consider creating structure contains array easier copy array copying structure one. the definition , declaration of structure this: typedef struct { char array[x]; /* x arbitrary constant */ } array; array array1; then, perform copy doing: array array2; array2 = array1; i have found fastest way of copying array. have disadvantage? edit: x arbitrary constant, let's 10. array not variable length array. this works fine, since x must defined @ compile-time rather inflexible. can same performance on array of length using memcpy instead. in fact, compilers translate array2 = array1 call memcpy . as mentioned in comments, whether direct assignment gets translated memcpy call depends on size of array amongst other compiler heuristics.

setup and cleanup methods of Mapper/Reducer in Hadoop MapReduce -

are setup , cleanup methods called in each mapper , reducer tasks respectively? or called once @ start of overall mapper , reducer jobs? they called each task, if have 20 mappers running, setup / cleanup called each one. one gotcha standard run method both mapper , reducer not catch exceptions around map / reduce methods - if exception thrown in these methods, clean method not called.

eclipse plugin - Android not able to show result in my device -

i new android. when running android application in eclipse getting these messages in console: [2012-06-04 22:51:00 - interface] ------------------------------ [2012-06-04 22:51:00 - interface] android launch! [2012-06-04 22:51:00 - interface] adb running normally. [2012-06-04 22:51:00 - interface] performing yassine.ana.kantester.interfaceactivity activity launch [2012-06-04 22:51:00 - interface] automatic target mode: using device 's557083c795c2' [2012-06-04 22:51:00 - interface] uploading interface.apk onto device 's557083c795c2' [2012-06-04 22:51:01 - interface] installing interface.apk... after message nothing displayed in device ,same problem when use emulator tested app samsung s5570 and here androidmanifest.xml file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="yassine.ana.kantester" android:versioncode="1" and...

android - Adding a color filter to a Drawable changes all Buttons using the same Drawable -

i have screen multiple buttons use same background drawable. have reusable code use in various projects add ontouch listener adds gray color filter while button being touched. works fine, in case buttons tinted when of them pressed. i see explanation in http://developer.android.com/guide/topics/graphics/2d-graphics.html : note: each unique resource in project can maintain 1 state, no matter how many different objects may instantiate it. example, if instantiate 2 drawable objects same image resource, change property (such alpha) 1 of drawables, affect other. the suggested solution use tweenanimation, not seem work color filters. i saw android: cloning drawable in order make statelistdrawable filters suggests using drawable.getconstantstate().newdrawable(). not seem make difference. i'm guessing long same physical image file used, drawables affected change other drawable using same resource. what solution there, other creating second background image show p...

ios - Two rows only UITableView -

i'm using uitableview control on nib 1 section , set delegate/data source controller "table data" array initialized 2 items only. however, i'm seeing additional empty rows being rendered in table view when run in simulator. how can make uitableview render 2 rows? thanks! i having similar problem, how show separators cells contain data. tableview renders many rows can fit area allocated (width , height). number designate in numberofrowsinsection used determine how many times should call cellforrowatindexpath . to overcome the rendering of separator lines empty cells did following: disable separators whole tableview. can in inspector tableview in interface builder or calling [yourtableview setseparatorstyle:uitableviewcellseparatorstylenone]; . inside cellforrowatindexpath populate tableview cells create new uiview , set subview cell. have background of view lightgray , transparent. can following: uiview *separatorview = [[uiview alloc] initwi...

regex - Perl regular expression for partially matching an ip or mac address -

i'm writing optimization performing search application , if string looks ip address, don't bother searching mac addresses. , if search looks mac address, don't bother looking in ip address db column. i have seen expressions match ips , mac addresses exactly, hard come 1 matches partial strings , quite fun brain teaser , thought i'd other people's opinions. right have solution without regex. use list::util qw(first); sub query_is_a_possible_mac_address { ($class, $possible_mac) = @_; return 1 unless $possible_mac; @octets = split /:/, $possible_mac, -1; return 0 if scalar @octets > 6; # fail long macs return 0 if (first { $_ !~ m/[^[:xdigit:]]$/ } @octets; # fail non-hex characters return not first { hex $_ > 2 ** 8 }; # fail if number big } # valid tests '12:34:56:78:90:12' '88:11:' '88:88:f0:0a:2b:bf' '88' ':81' ':' '12:34' '12:34:' 'a' '' # invalid test...

java - hyperlinkUpdate() gives me NullPointerException every time i click a hyperlink in the JEditorPane? -

i want add initial file loaded javadoc has names of classes, want display corresponding page each class when click on hyperlink it's name, when did prints in console didn't see problems gathering corresponding url nullpointerexception every time try add jeditorpane. here's program: import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; public class implements hyperlinklistener { jeditorpane htmlpane; string url = "file:///f:/java%2012/isp/help%20file%20try/doc%202/allclasses-frame.html"; public void hyperlinkupdate(hyperlinkevent event) { if (event.geteventtype() == hyperlinkevent.eventtype.activated) { try { htmlpane.setpage(event.geturl()); //url.settext(event.geturl().toexternalform()); //system.out.println(event.geturl().tostring()); } catch(ioexception ioe) { // system.out.print("err"); ...

pattern matching - RegEx: grouping returns only the last match -

i've set of strings in form: nooo (2), { aaa (1), bbb (2), ccc-cc (3), ddd (4) } (elements can more 4 inside brackets) i need match contents inside brackets , extract (using groups) 'aaa', 'bbb', ... substrings. result example be group1 : aaa group2 : bbb group3 : ccc-cc group4 : ddd i tried expression: \{ (?:(\s+) \(\d+\),?\s?)+ \} but returns last matched group (so, in case, 'ddd'). missing? thanks if using .net regex expression work capturing group capture values. otherwise have use more tricky regex or match in 2 steps, first matching { ... } group , elements in it. the tricky regex like: (?:{|\g(?!^),) # match { or previous match ended followed , \s+ # space between elements (\s+)\s+\(\d+\) # element (?=[^{]*}) # make sure it's followed } you can use expression it's written if use /x flag (can set adding (?x) in beginning of expression). the regex without comments: (?:{|\g(?!^),)\s+(\...

c# - Any better way to determine the type based on T and subclass -

writing bit of code deals response , request. both can in form of xml, , both can in form of c# object created through transform , serialization. (this .net 2.0) response , request base implementations of larger message types. right have geteligibility , findcandidates. example of model.messagemodel classes used below: public partial class geteligibilityresponsemessage : responsemessage public partial class responsemessage : message because won't want duplicate mapping functionality i've decided use generics simplify process, , it's working out great: base class code public virtual model.messagemodel.message maptomodel<t>(xmldocument xml) { v3mapper mapper = new v3mapper(); model.messagemodel.message message = mapper.maptodomainmodel<t>(xml, environment) model.messagemodel.message; return message; } public virtual xmldocument maptoxml<t>(model.messagemodel.message message) { v3mapper map...

mono - MonoDroid - How to use DialogPreference? -

Image
i trying implement dialogpreference subclassing dialogpreference class , declaring in preferences xml file. when call addpreferencesfromresource in preferenceactivity system.notsupportedexception. cannot catch exception copy have couple of screen shots below of looks when exception thrown. i have copied , coverted code dialogpreference here . how can implemented in mono android? this xml dialogpreference: <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android"> <preferencecategory android:title="opening odds"> <app.monodroid.timepickerpreference android:key="openoddstime" android:title="opening odds time" android:dialogmessage="time of day opening odds." android:defaultvalue=""> </app.monodroid.timepickerpreference> </preferencecategory> screenshots: t may wrong, i'm pretty sure ate missing constructor takes 2 argume...

Android (ActionBarSherlock) Is there any way to keep the same ActionBar height both in portrait and landscape? -

Image
i have been working actionbar , actionbarsherlock last few days, , having issues when filling information in actionbar. when application runs in portrait mode, actionbar looks fine, , data can displayed, example: but when switch app displayed in landscape, of data cropped: you can notice how both status icon , email has been cropped due new height of actionbar. in case, want keep same size portrait , landscape app can fine. can't reduce font size of action bar title, since may include other icons. the way i´m putting these icons in action bar title , subtitle using html.fromhtml any ideas solve problem? using actionbarsherlock library! one, not pretty approach, override default height values actionbar in dimens.xml . e.g. default value in portrait is: <dimen name="abs__action_bar_default_height">48dip</dimen> and in landscape: <dimen name="abs__action_bar_default_height">40dip</dimen> there might cle...

asp.net - ASP .net 4.0 CSS .page width not applying -

first question, nice! ;-) working visual studio 2010, have created basic framework 4.0 website normal c# web site template. looking edit .css given ms. just proof of concept take default 960px .page width , change 550px. have changed manually via code directly , i've tried via manage styles toolbar. new width applies in design view, when running in browser can confirm inspecting applied style 960px. (changing 960 550 in firefox's css editor works...) i have restarted vs2010, computer, have rebuilt solution, rebuilt web site , published iis externally. .css editing not applying page. .page { width: 550px; background-color: #fff; margin: 20px auto 0px auto; border: 1px solid #496077; } for may less familiar vs2010 am, .page style appears place has stated width, , @ 960px indeed set width whole site. .css file working generated 1 located @ |projectdirectory|/styles/site.css any ideas?

iphone - D3.js to manage Webkit translate3d : Is that possible? -

does know how use css3 webkit translate3d instead of normal left css d3.js. on iphone translate3d run faster , need on transition after release of html element. here code left css : d3.select("#myhtmlelem").transition() .style("left", mynewposx) + "px") .duration(500) .ease("cubic-in-out") .each("end", function(d) { // after }); there jquery, prefer keep using d3.js project. idea how make previous code using translate3d instead of left property? thanks this how it. smooth/functional transition, make sure apply default values style attribute before transition executed on element. default style (before transition): var svg = d3.select("div#wrapper").append("svg").append("g").attr("id", "usg").attr("style", function () { return "-webkit-transform: perspective(800) scale(1) scale3d(1, 1, 1) rotate3d(1, 0, 0, 0deg) translate3...

actionscript 3 - (AS3) Two arrays associated? Change on one changes the other -

when splice entry 1 array, splices same entry other array... happening? private static var words:array = new wordfile().tostring().split(/\n/); private static var wordstemp:array; public static function checkword (word:string):boolean { var truefalse:boolean = wordstemp.indexof(word+"\r".tolowercase()) > -1; trace (words.length) wordstemp.splice(wordstemp.indexof(word+"\r".tolowercase()), 1); trace (words.length) return truefalse } public static function resetarrays :void { wordstemp = words } with code, call resetarrays function every time new game started. once in game, program call checkword word being passed it. if found in word array, splice temporary array. however, when run it, 2 traces yield 2 different numbers, second 1 being 1 lower (assuming word found in array). seems me strange splicing temporary array gets reset, when tracing array supposed unchanged (there no operati...

javascript - How do you store a googol in the database (and other very large numbers)? -

how efficiently store large , small numbers 10^-100 10^100 , can use them calculate values in programming language javascript. javascript stores 10^100 1e+101 , there way in database? numbers not large, calculations data such 10^-34 * 2^16 or whatever, database should (i think) storing these numbers... how work? how store numbers of scale such can run computations them? by "the database", i'm thinking in general. messing around mongodb , neo4j currently. databases don't support numbers of arbitrary size in native numeric format. general upper limit on numeric types 8 bytes, isn't anywhere near googol. you'll have store number either string (least efficient, easiest work with, can precise needed), byte array of arbitrary length (more efficient, harder work with, still arbitrary precision), or in scientific notation (most efficient, harder work with, , limited precision). the first two, unfortunately, eliminate possibility of doing s...

parsing - JavaCC grammar conflict -

i have grammar defined this. token:{ <t_int: "int"> | <t_string: ["a"-"z"](["a"-"z"])*> } skip: { " " | "\t" | "\n" | "\r" } /** main production. */ simplenode start() : {} { (lookahead(declaration()) declaration() | function()) { return jjtthis; } } void declaration() #decl: {} { <t_int> <t_string> ";" } void function() #func: {} { <t_string> "();" } this works fine stuff like: int a; foo(); but when try int(); , legal me , should parsed function(), goes declaration instead. how fix "conflict"? tried various combinations. the javacc faq's section on titled " how deal keywords aren't reserved ?". what allowing keywords alternatively identifiers, i.e. (<t_string> | <t_int>) "();" when there many keywords, beneficial create ident...

javascript - new date() formatting -

i've been stuck on while , need help. have date/time displayed using "new date()" . works perfect except in need display yyyy mmm dd hh:mm:ss. displays " thu may 31 2012 13:04:29 gmt-0500 (cdt) ". need " 2012 may 31 13:04:29 ". any awesome! thanks i love using moment.js when i'm doing lots of complex , different date formatting, should work too: var m_names = new array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"); var mydate = new date(); var curr_date = mydate.getdate(); var curr_month = mydate.getmonth(); var curr_year = mydate.getfullyear(); var mydatestr = '' + curr_year + ' ' + curr_month + ' ' + curr_date+ ' ' + mydate.gethours() + ':' + mydate.getminutes() + ':' + mydate...

objective c - Generic typeof for weak self references -

i trying figure out way use typeof create weak reference self use in blocks avoid retain cycles. when first read seems convention use __block typeof(self) bself = self; , compiles using __block avoid retain cycles doesn't work anymore , __weak should used instead. however __weak typeof(self) bself = self; results in error: the type 'typeof (self)' (aka 'tuaccountsviewcontroller *const __strong') has retainment attributes set on it is there way use typeof or call generically create weak reference self ? in latest clang version apple clang version 4.0 (tags/apple/clang-421.1.48) (based on llvm 3.1svn) , i.e. xcode 4.4+ , __typeof__((__typeof__(self))self) trick not necessary anymore. __weak typeof(self) bself = self; line compile fine.

ruby on rails 3 - Markitup custom bbcodes -

i trying create simple bbcode-enabled text-editor couple codes, need create custom codes , buttons them such [cut=#{line}]#{text}[/cut] , [talk]#{text}[/talk]. , not find manual showing how in markitup. update i'm using rails on server-side , have set bb-ruby treat custom bb-codes safely, need include them in markitup setup. you can download bbcode set , add custom button it. the documentation , section magic markups explaining how add , customize buttons.

walking and averaging values in python -

i have process .txt files presnent in subfolder inside folder.like: new folder>folder 1 6>xx.txt & yy.txt(files present in each folder) each file contain 2 columns as: arg asp gln glu and arg glu arg arg glu asp now have : 1)count number of occurance of each word each file > , average total count dividing total no. of lines in file 2)then values obtained after completing 1st step, divide values total no. of files present in folder averaging (i.e. 2 in case) have tried code follows: have succeeded in 1st case i'm not getting 2nd case. for root,dirs,files in os.walk(path): aspcount = 0 glu_count = 0 lys_count = 0 arg_count = 0 his_count = 0 acid_count = 0 base_count = 0 count = 0 listoffile = glob.iglob(os.path.join(root,'*.txt') filename in listoffile: linecount = 0 asp_count_col1 = 0 asp_count_col2 = 0 glu_count_col1 = 0 glu_count_col2 = 0 lys_count...

android - How to check date from sqlite database? -

i have sqlite database table contacts friend , contacts date of birth.i want ring alarm when date match database current date.please me how task. want match date 2 time day daily please suggest me. i using code private void setalarm(string name,string date) { string[] arrdob =date.split("/"); calendar cal = calendar.getinstance(); //for using need import java.util.calendar; // add minutes calendar object cal.set(calendar.month,integer.parseint(arrdob[1])); cal.set(calendar.year, integer.parseint(arrdob[2])); cal.set(calendar.day_of_month,integer.parseint(arrdob[0])); cal.set(calendar.hour_of_day,14); cal.set(calendar.minute,35); system.out.println("1"); intent alarmintent = new intent(getapplicationcontext(), alarmreceiver.class); alarmintent.putextra("title","b'day alarm"); alarmintent.putextra("subject","hi!todays "+name+...

Issue with javascript date object -

Image
i facing weird problem while initializes javascript date object,no matter initialize shows date 1 jan 1970 05:30; this way try initialize var d=new date(27-02-1989); alerting 'd' shows 1 jan 1970.....,also takes date passed database in format mm/dd/yyyy not in format want i.e dd/mm/yyyy this problem has popped-up, working smooth couple of days ago,but today after opening project (after 2 days) issue irritating me // transform european date in rfc compliant date (american) var date = '27-02-1989'.split('-').reverse().join('-'); // , works var d = new date( date ); proof:

tomcat - Java "Out of memory error" - heap/system - where to look? -

in tomcat application getting "out of memory" , "cannot allocate memory" errors. suppose nothing heap fulls system memory , hardly able run bash commands. how problem connected heap? how can correctly set heap size application has enough memory , not consume of system resources? strange thing "top" command keeps saying tomcat consumes 20% of mem , there still free memory, once problem happens. thanks. edit: follow-up: bufferedimage leaks - there alternatives? problems running bash scripts may indicate i/o issues, , might case if jvm doing full gcs time (which case, if heap almost-full). the first thing do, increase heap -xmx . may solve problem, or - if have memory leak, won't, , outofmemoryerror again. in case, need analyze memory dumps. see my answer in thread instructions. also, might useful enable garbage collection logs (using -xloggc:/path/to/log.file -xx:+printgcdetails ) , analyzing them gcviewer or hpjmeter . ...

caching - Memcache tags simulation -

memcached great scalable cache layer have 1 big problem (for me) it cannot manage tags . , tags useful group invalidation. i have done research , i'm aware solutions: memcache tag fork http://code.google.com/p/memcached-tag/ code implementation emulate tags (ref. best way invalidate number of memcache keys using standard php libraries? ) one of favorite solution namespace, , solution explained on memcached wiki . however don't understand why integrate namespace on key cache? from understood namespace trick is: generate key have value of namespace (on cache). , if namespace->value cache entry evicted, can no longer compute key fetch cache... cache namespace virtually invalidate (i said virtually because cache still exist can no more compute key access). so why can not implement like: tag1->[key1, key2, key5] tag2->[key1, key3, key6] key1->["value" => value1, "tags" => [tag1, tag2]] key2->["value" => ...

ios - Adding reachability to iphone application gives linking errors -

Image
i keep getting these errors trying run reachability.h go project build phases , add following under compile sources , press "+" icon , add reachability.m under link binary libraries press "+" icon , add systemconfiguration.framework update: if receiving arc compilation errors have disable arc on specific files please follow steps in answer how can disable arc single file in project?

javascript - Image Preview with jQuery, How to remove the a href click event -

this should not complicated: i using easiest tooltip , image preview using jquery trying use example how can disable click event on original picture, want tooltip displayed (i don't want allow click on picture) how can done? thanks! this current style: <style> #preview{ position:absolute; border:1px solid #ccc; background:#333; padding:5px; display:none; color:#fff; } </style> this javascript: this.imagepreview = function(){ /* config */ xoffset = 10; yoffset = 30; // these 2 variable determine popup's distance cursor // might want adjust right result /* end config */ $("a.preview").hover(function(e){ this.t = this.title; this.title = ""; var c = (this.t != "") ? "<br/>" + this.t : ""; $("body").append("<p id='preview'><img src='"+ this.href ...

xampp - download file with php -

i wondering. have 2 computers 1 installed xampp , other 1 not.(same network). both windows xp and making script test download file. <?php $txt = "http://www.branded3.com/wp-content/uploads/2011/05/google_chrome1.jpg"; $img = "01.jpg"; file_put_contents($img, file_get_contents($txt)); ?> and run script on computer xampp installed, , absolutely works. but running on computer, not working. can me in issue? heres crude way can proxy image , prompt download. <?php $url = "http://www.branded3.com/wp-content/uploads/2011/05/google_chrome1.jpg"; //get file $source = file_get_contents($url); //image mime types $images = array('jpg'=>'image/jpg','png'=>'image/png','png'=>'image/png'); //is image extention if(in_array(substr($url,-3),$images)){ $type = $images[substr($url,-3)]; }else{ //no somthing else $type = 'application/octet-stream'; } //set headers he...

c# - How to show foreign key value in editmode (detailview)? -

i have little problem gridview. in editmode load dropdownlist content database (foreign key!). when save changes , go after again in editview, dropdownlist shows first entry table , not value value saved. how can set default value in dropdown value, set in database, when go in editmode? i hope concern understandable. thank helping! my code (shorted) <asp:detailsview id="dtvprojektdetails" runat="server" datasourceid="sqlprojectdetails" autogeneraterows="false" datakeynames="projectid" defaultmode="edit" onitemupdating="dtvprojektdetails_itemupdating"> <fields> <asp:templatefield headertext="segment" sortexpression="fk_segment"> <edititemtemplate> <asp:dropdownlist id="ddlsegment" runat="server" datasourceid="sqldssegment" datatextfield="segment" datavaluefield="segid"> </asp:drop...

java - Localhost address in the Virtual Machine -

i using virtual machine on server. local ip of vm 192.168.1.10 i trying achieve requires me edit /etc/hosts provided in link http://www.thatisjava.com/java-tech/55200/ i having similar problems, console reads rtp--- :dataaddress: /192.168.1.10 controladdress: /192.168.1.10 dataport: 42050 controlport: 42051 java.io.ioexception: local data addressdoes not belong of hosts local interfaces java.io.ioexception: local data addressdoes not belong of hosts local interfaces @ org.speechforge.cairo.rtp.rtpconsumer.init(rtpconsumer.java:181) @ org.speechforge.cairo.rtp.rtpconsumer.<init>(rtpconsumer.java:95) @ org.speechforge.cairo.rtp.server.rtpstreamreplicator.<init> (rtpstreamreplicator.java:69) and more. the answer problem given i solved one. problem jmf seems use inetaddress.getallbyname() returns (at least in case) single ip address no matter how many addresses have defined on interfaces. problem solved placing ip address wanted use sess...

node.js - Direct browsing of a resource -

is there possibility of "direct browsing of resource" attack in node js applications , how can prevent it? edit : use express framework node.js http servers not serve static content, call code. if there possibility attack in code, not in node.js core or in http module. regarding edit: express provides static middleware, open possibility direct browsing attack, if configure serve static files directory contains sensitive resources. if keep dedicated directory static content, of safe browsed directly, , there no sensitive content below directory, you'll safe if serve express' static middleware.

php - List with duplicate entries -

i got minor problem. start, have following tables: 'groups', 'pages' , junction table 'subcriptions' the idea behind group (with users) can subsribe page. user can add page subscription group in. (many-to-many). information: user can in multiple groups. as part of ui want make list that. every group want associated pages. example: (group: ... pages: -.... , -.... | group: ... pages: -...., -.... etc.) the sql query not issue: select groups.name, pages.name, pages.id groups join subscriptions on groups.id = subscriptions.group_id join pages on subscriptions.page_id = pages.id groups.id in ('1', '2') // de values 1 & 2 zijn voorbeelden en stellen de groepen id's voor waarin de huidige gebruiker zit. the result will, example, this: group name ---- page name ---- page id group1 -------- page1 --------- 1 group1 -------- page2 --------- 2 group2 -------- page1 --------- 1 my question is; how can (html) list single group...

internet explorer 9 - IE9 Separate cookies for third party request -

even though p3p headers correct, ie9 seems hold separate list third party requests. i've added following p3p header('p3p:cp="noi dsp cor cura adma deva psaa psda our bus ind uni com nav int", policyref="http://domain/w3c/p3p.xml"') of course domain set. it's created ibm tool. next i've created p3p xml file , tested p3p validation. once call test file stating nothing more then <?php header ('p3p:cp="noi dsp cor cura adma deva psaa psda our bus ind uni com nav int", policyref="http://padrichem.ds1.nl.dev/w3c/p3p.xml"'); session_start(); var_dump($_cookie); it says $_cookie empty, refresh , says $_cookie[phpsessid] = 'id' now call same file remote location within iframe says $_cookie empty, refresh , says $_cookie[phpsessid] = 'different id' when disable protected mode isn't case. yet isn't case on domains. on harddrive can find cookies set iframe (third-...

java - How to rectify this program? -

this program display pie chart. have button. program have written, creates 2 separate frames , 1 frame pie chart , other button. how put both button , pie chart on same frame?? can please rectify program. import java.awt.*; import org.jfree.chart.*; import org.jfree.chart.title.*; import org.jfree.data.general.defaultpiedataset; import org.jfree.ui.*; import java.io.*; import javax.swing.*; import java.awt.event.*; import javax.swing.filechooser.*; public class pie{ public static void getfile(file f) { system.out.println("file is: "+f.getname()); } public static void main(string[] args) { jpanel panel=new jpanel(); panel.setlayout(null); jbutton b=new jbutton("open file"); b.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { jfilechooser chooser=new jfilechooser(); int ret = chooser.showdialog(null, "open file"); if (ret == jfilechooser.ap...