Posts

Showing posts from January, 2011

Android push c2dm Not working with a 200 ok reponse -

i've been trying send push message java ee web app, android phone. i've followed , read lot of tutorial (like 1 http://www.vogella.com/articles/androidcloudtodevicemessaging/article.html ) i registration_id on android phone. sent post request witch sent me "200 ok" response ! but can't nothing on broadcastreceiver... the "200 ok" response mean message been send ? can ? thanks guys ;) there few things check here. did declare receiver messages in manifest? seperate receiver when application receives messages. ensure package name matches yours. should similar too: <receiver android:name=".c2dmmessagereceiver" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" > </action> <category android:name="jakebuller.liveapp" /> </intent-fi...

css - Hover fade effect via jQuery -

i've got class: #right_menu { color: #002c6a; display: block; font-family: 'dinpro-bold'; font-size: 15px; height: 20px; padding: 15px 0 15px 95px; width: 205px; } and hover css: #right_menu a:hover { color: #fff; font-size: 15px; font-family: 'dinpro-bold'; background-color:#002c6a; } it's working. want when hover, fade effect via jquery. how can do? use js file jquery-ui-1.8.11.min.js may you.

sed - How can I emulate `uniq -d` in awk? -

i've got busybox system doesn't have uniq , i'd generate unique list of duplicated lines. a plain uniq emulated in awk be: sort <filename> | awk '!($0 in a){a[$0]; print}' how can use awk (or sed matter, not perl ) accomplish: sort <filename> | uniq -d could (needn't sort it): awk '{++a[$0]; if(a[$0] == 2) print}'

php - looping though and remixing $var -

ok, having small issue, need loop though $usd,$aud etc , possible currency exchange rates e.g $usd:$aud - $aud:$usd, $usd:$nzd - $nzd:$usd here code using <?php $usd = 'usd'; # usa dollar $nzd = 'nzd'; #new zealand dollar $kwd = 'jpd'; #japanese dollar $gbp = 'gbp'; #uk pound $aud = 'aud'; $url = 'http://finance.yahoo.com/d/quotes.csv?f=l1d1t1&s='.$gbp.$aud.'=x'; $handle = fopen($url, 'r'); if ($handle) { $result = fgetcsv($handle); fclose($handle); } echo '1 '.$aud.' worth '.$result[0].' '.$usd.' based on data on '.$result[1].' '.$result[2]; ?> what need away make sure looks @ different ways rates go together. my first thought while or loop not sure, help $currencies = array($used, $nzd, $kwd, $gbp, $aud); foreach ($currencies $from) foreach ($currencies $to) if ($from != $to) // query api conversion $from $to

java - HttpPost - type of http request method -

hi :) got simple problem, annoying. i'm trying send http post request using httppost class this part of method returns inputstream: httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url+path); arraylist<namevaluepair> paramslist = new arraylist<namevaluepair>(); paramslist.add(new basicnamevaluepair("key1", value1)); paramslist.add(new basicnamevaluepair("key2", value2)); paramslist.add(new basicnamevaluepair("key3", value3)); httppost.setentity(new urlencodedformentity(paramslist)); httpresponse httpresponse = httpclient.execute(httppost); httpentity httpentity = httpresponse.getentity(); inputstream = httpentity.getcontent(); return is; but problem on server, because server "thinks" im sending request instead of post. question is: mistake? im using similar part of code in other application , wo...

linux - Nagios verify Sharepoint -

i want set nagios (on debian) verify sharepoint server up. tried use curl didn't worked issue don't know decided change way i'll verify service. it's simple in theory, have make script send request (http or https, doesn't matter) , check response, if 200 successful or 40x if not (ok @ point). so have use telnet or ftp service or can use feature/tool that. with telnet i'am having problem 400 error. sharepoint returns error when server or down, don't work me. any ideas?? you can use check_http plugin of nagios. example: check_http -h sharepointhostname/ip -p port you can use -s flag secure http connections you can use -u flag going specific url you can use -s flag search specific string in html page returned url specified -u flag. so can request specific page, scan known string, , if found, sure page (which means server etc.) example: check_http -h my.sharepoint.com -u /start/page/sharepoint.aspx -s "test string"...

Data values in the parameters are beeing copied to the other parameters c++, c# -

in c++ method exporting is: __declspec(dllexport) int __thiscall a::check(char *x,char *y,char *z) { temp=new b(x,y,z); } in c# importing method this: [dllimport("idll.dll", callingconvention=callingconvention.thiscall, exactspelling = true, entrypoint = "check")] public static extern int check(string x, string y, string z); i calling method in c# , passing values: public int temp() { string x="sdf"; string y="dfggh"; string z="vbnfg"; int t; t=class1.check(x,y,z); return t; } the problem when debug in native code see parameters x,y,z having values sdf,dfggh,vbnfg , being altered when reach c++ dll before entering native c++ dll method. x=dfggh,y=vbnfg,z=null value and giving me error saying null pointer value passed function. can 1 me out fixing weird problem. looks native method instance(vs static) method. guess first parameter gets mapped 'this' somehow. here example: #inclu...

encryption - How to encrypt cart data send to paypal -

i have cart , when user purchase , check out data send paypal. have checked using firebug can see data has been posted paypal site. sample data posted paypal below address1 unit 1 stirling park address_override 1 amount_1 350.00 amount_2 11.00 amount_3 72.20 business msindia@bba-reman.com cancel_return http://www.msindia.com/catalogue/order/paypalfailure.aspx city rochester cmd _cart cn how did hear us? country gb currency_code gbp first_name ben invoice pp001250 item_name_1 marea 2.4 td item_name_2 carriage item_name_3 vat amount item_number_1 0281001741 last_name walker notify_url http://www.msindia.com/catalogue/order/paypalnotify.aspx return http://www.msindia.com/catalogue/order/paypalsuccess.aspx state kent upload 1 zip me9 3qq is there trick can encrypt data , send paypal paypal understand encryption , populate form incoming data. please guide if 1 has prior experience. thanks

ruby on rails - Using Devise/Cancan/Rolify together -

i'm trying set authorization/authentication system, , i'm getting confused, have couple of questions: in lot of tutorials, people set user/role habtm relationship. allows each user have multiple roles, if want each user have 1 role, necessary? if want have options "active" , "inactive" users, should roles or else? in cancan wiki, says if want 1 user have 1 role, should make attribute , use "can :manage, :all if user.role == "admin"", isn't dangerous because each time "admin" string? matter? what's better way deal this? i've tried best read through documentation involved , started tutorial http://railsapps.github.com/tutorial-rails-bootstrap-devise-cancan.html although i've read http://starqle.com/articles/rails-3-authentication-and-authorization-with-devise-and-cancan-part-1/ , tonyamoyal.com/2010/09/29/rails-authentication-with-devise-and-cancan-part-2-restful-resources-for-ad...

javascript - add inline css to body in tinymce -

i'm importing html external source tinymce. have 2 questions: if tinymce.execinstancecommand('mce_editor_0','mcesetcontent', false, myvar); , myvar has doctype , header etc defined, seems take body content. correct behavior? since myvar has inline css within body tag , mcesetcontent() doesn't import it, need pass myself. how can add inline css body of tinymce instance? thanks this correct bahaviour. paste goes editors iframe body. doctype , css stuff not. thing use paste setting paste_preprocess , filter css stuff out , insert editors ifram head.

python - model and instance methods: session aware (sqlalchemy) -

so, using , learning sqlalchemy. i have instance, need value. if value exists, return it. if not calculate , return it. invariably 'you're doing wrong' , input on improvement appreciated in general. looking how can without explicitly having manage session, because i'm working on starting grow, , managing session when want update instance problematic. makes me think am in fact doing wrong. so how fix method below not have manage session explicitly? def method(self, session): if self.i_needed_this none: self.i_needed_this = calculate(calcutron) session.add(self) session.commit() return self.i_needed_this else: return self.i_needed_this maybe question should titled 'making instances session aware i'm not explicitly managing it', , if it's dumb question, @ least show me why examples , point me others have asked better. edit: apparently, impor...

java - Dirty Checks: JSF + Primefaces application? -

i have web application in using jsf + primefaces ui. facing difficulty in applying dirty checks on web pages specially when working ajax calls ajax call on rowselect event of datatable. following exact scenario in want apply dirty checks ajax call. following components using in web page. 1) have 1 datatable populated bean named 'companybean' (having attributes companies) <p:datatable id="basic" var="company" value="#{companyinfobean.companylist}" rowkey="#{company.id}" selection="#{companyinfobean.selectedcompany}" selectionmode="single"> <p:ajax event="rowselect" update=":customerdataform:customerdatafields" /> <p:column id="modelheader"> <f:facet name="header"> <h:outputtext value="company name" /> </f:facet> <h:outputtext value="#{company.companyname}" /...

clojure - Why does read-line not return after hitting ENTER (seems like a hang) using lein run, but works with lein repl? -

the problem @ hand when run program lein run gets (read-line) part , can't out of it, meaning: read-line never returns. here relevant code: (def command (atom "")) (defn print-prompt [] (print "prompt> ") (flush) ) (defn ask-for-input [] (print-prompt) (let [x (str (read-line))] (println (str "user input: " x)) (reset! command x) ) ) i never see "user input: " string on screen. strange part is, if run lein repl , call (ask-for-input) works correctly :s try lein trampoline run , works. the following leiningen faq: q: don't have access stdin inside project. a: limitation of jvm's process-handling methods; none of them expose stdin correctly. means functions read-line not work expected in contexts, though repl task includes workaround. can use trampoline task launch project's jvm after leiningen's has exited rather launching subprocess.

php - Javascript function not being called from onchange (not always) -

at moment, i'm in process of creating website, have products have quantity. quantity depends on size , color. so came following procedure check , give feedback how many there still left. <div class="product_stock" id="stock_form<?php echo $i; ?>"><?php $size = $product_sizes[0]; $color = $product_colors[0]; $sql = "select * products product_id = '$product_id' , size = '$size' , color = '$color'"; $result = mysql_query($sql) or die(mysql_error()); echo $sql; if(mysql_num_rows($result) > 0) { $product_stock = mysql_fetch_array($result); if($product_stock['stock'] > 0) { echo "nog ".$product_stock['stock']." verkrijgbaar"; } else { echo "combinatie niet meer verkrijgbaar"; } }?> </div> <div class="product_text"> <?php echo $product['text']; ?> </div> <div...

Xmpp connection using asmack and bonjour on android -

i'm trying server-less app im. use apple bonjour protocol discover xmpp services. once can't connect host (linux computer using pidgin + bonjour). here code (taken here ) : public class xmpp extends asynctask<void, void, void> { @override protected void doinbackground(void... arg0) { connectionconfiguration connconfig = new connectionconfiguration("192.168.0.11", 5298, "bonjour"); xmppconnection connection = new xmppconnection(connconfig); try { // connect server connection.connect(); // servers require login before performing other tasks. connection.login("grea08", "mypass"); // start new conversation john doe , send him message. chat chat = connection.getchatmanager().createchat("grea09@192.168.0.11", new messagelistener() { public void processmessage(chat chat, ...

PowerShell- adding files to a .zip archive, need to preserve the directory structure -

i'm using following function add files .zip archive works fine, need able include parent directory of files. ideas? function add-zipfile { param([string]$zipfilename, [string]$filter) if(-not (test-path($zipfilename))) { set-content $zipfilename ("pk" + [char]5 + [char]6 + ("$([char]0)" * 18)) (dir $zipfilename).isreadonly = $false } $shellapplication = new-object -com shell.application $zippackage = $shellapplication.namespace($zipfilename) $files = get-childitem -filter "$filter" -recurse foreach($file in $files) { $zippackage.copyhere($file.fullname) start-sleep -milliseconds 500 } } based on knowledge cannot add zip file 1 specific file using shell.application , saving folder structure. have 2 choice: add single files in flat structure script do add 1 folder , content ( save structure folder using folder added parent folder): $directory = get-ite...

c# - assigning value to bool inside while loop -

i know newbie c# question implementing small program following: namespace consoleapplication { class program { static void main(string[] args) { bool isrun = false; int number = 0; while (isrun = (true) && number < 3) { ++number; console.writeline("number = {0}", number.tostring()); console.writeline(); } console.writeline(isrun.tostring()); console.readline(); } } } at end of while loop, have expected bool value true, is printed false . why that? different c++ have done , same thing in c# giving me false while(number<3) { = true; } if(is){ cout<<true; } the reason you're seeing behavior due operator precedence involved. here && binds more = code in loop bound following while (isrun = (true && number < 3)) { ... } once number > 3 ...

java - Axis2 / SOAP, return List<myIObject> produce empty return -

so have piece of code producing soap serivce in java, wrapping python code through jython on tomcat/axis2 server... , works! i have method return public static list<myclass> dosomething() but soap answer empty data: <soapenv:envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:body> <ns:domyserviceresponse xmlns:ns="http://mypyinterface" xmlns:ax23="http://mypyinterface/xsd"> <ns:return xsi:type="ax23:myclass" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> <ns:return xsi:type="ax23:myclass" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> <ns:return xsi:type="ax23:myclass" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> <ns:return xsi:type="ax23:myclass" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/> <ns:return xsi:type=...

php - Can't publish a high score to player's timeline on Facebook -

i'm developing php game , post players highscores own facebook wall /timeline. i've set facebook app , php code i'm using post score (as provided facebook itself): <?php require 'facebook-sdk/facebook.php'; $app_id = my_app_id; $app_secret = my_app_secret; $score = 1500; // gonna passed someway... $facebook = new facebook(array( 'appid' => $app_id, 'secret' => $app_secret, )); $user = my_user_id; // replaced call $facebook->getuser() $app_access_token = get_app_access_token($app_id, $app_secret); $facebook->setaccesstoken($app_access_token); $response = $facebook->api('/' . $user . '/scores', 'post', array( 'score' => $score, )); print($response); // helper function app access token function get_app_access_token($app_id, $app_secret) { $token_url = 'https://graph.facebook.com/oauth/access_token?' . 'client_id=' . $app_id . '...

delphi - How to render WebBrowser to device context? -

i want render web-page (i.e. twebbrowser ) device context. want use internet explorer's layout engine render content device context (i.e. metafile, pdf metafile). starting internet explorer 9 ihtmlelementrender interface no longer supported : ihtmlelementrender interface use interface draw contents of element specified device context, printer. members ihtmlelementrender interface inherits iunknown interface not have additional members. to point no longer mention drawtodc method exists: ihtmlelementrender::drawtodc method deprecated. draws contents of element specified device context. syntax hresult drawtodc( hdc hdc ); parameters hdc [in] hdc specifying device drawn to, typically printer. return value returns s_ok if successful, or error value otherwise. remarks as of windows internet explorer 9, method deprecated , should not used. with printers, running ihtmlelementrend...

c++ - dynamic linking with LLVM -

i want execute functions in module, module have dependencies resolved in other modules. modules might change (dynamic compilation environment) prefer not not link dependencies in single monolithic module, is, if can avoided i hope use linker::linkmodules destructive on source module. ok 1 module depending on single one, since if 1 changed, no big deal, isn't overkill rebuild , relink n-1 modules did not change because of single 1 changed? i wonder if there non-destructive version of linkmodules can work jit execution. try this: linker::linkmodules(destinationmodule, sourcemodule, linker::preservesource, &error); if pass linker::preservesource instead of linker::destroysource , can continue use sourcemodule after call.

php - What is the best way to know is $_GET['example']=="somevalue"? -

if((isset($_get[example]))&&($_get['example']=='somevalue')){ ... } or if((!empty($_get[example]))&&($_get['example']=='somevalue')){ ... } or just if($_get['example']=='somevalue'){ ... } i asking why have seen many example people check first if $_get['example'] set , if $_get['example']=='somevalue' ( first , second example above ). don't understand why not use last solution ( if $_get['example']=='somevalue' $_get['example'] set ). this question refers other variable ( $_post, $_server, ecc ). if((isset($_get[example]))&&($_get['example']=='somevalue')){ ... } is right one, want know "variable" exists (or set) in order use it. empty checks wether has data of kind or not. example: <?php $foo= 0; if (empty($foo)) { // true because $foo empty echo '$foo either 0, empty, or not set @ all'; } ...

Wordpress Navigation remove container -

hi have problem wordpress navigation tools. want remove containing class. according documentation setting 'containter' => false removes containing class. but problem when have done so, nothing happened. <?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'container' => false ) ); ?> but when menu displayed still enclosed inside tag. do yo guys have idea how fix it? i found problem. forgot set header menu in functions.php , in admin panel well. register_nav_menus( array( 'header-menu' => __( 'header menu' ), 'footer-menu' => __( 'footer menu' ), ) ); make sure use both , in admin panel menus set correct menu container.

c# - Get selected files in Check In and Pending Changes window? -

my team not have option upgrade vs 2010, , cannot use gatedcheckin feature. developing visual studio plugin fill in gap. instead of coming replica of check in , pending changes window, i'd know if possible "hack" visual studio's. indeed, built-in window allows many things, including checking in subset of files pending changes via tree view/list view checkboxes. approach minimize learning curve of users of plugin, since can continue using familiar interface while our plugin work in background. how 1 go catching events sent inner elements of visual studio's tool windows? quite easy intercept check in button click (or right-click->check in... event on source explorer), have found no answer this. dialog accessible via _applicationobject.windows.item("{2456bd12-ecf7-4988-a4a6-67d49173f564}") but not uihierarchy, there no supported way obtain treeview of files pending changes. buddybuild, while sharing same purpose, has own gui , doesn't qui...

How to decorate nested attributes (associations) with Draper in Rails 3? -

my environment: rails 3.2 with draper gem i'm using nested resources , having trouble figuring out declare decorator. #app/controllers/users_controller.rb def show @user = userdecorator.find(params[:id]) @items = @user.items end #app/controllers/items_controller.rb def show @item = @user.items.find(params[:id]) end i tried replacing items itemdecorator , didn't work. should putting it? i know draper has issues nested resources in forms, isn't form! as far i've understood problem correctly, you've model user has many items , items not decorated? so add userdecorator : class userdecorator < draper::base decorates :user decorates_association :items #, :with => :item [..] end class itemdecorator < draper::base decorates :item [..] end have on the source .

ASP.NET Impersonation design -

this asp.net authentication operation. private void loginbutton_click(object sender, eventargs e) { string username = txtusername.value; string password = txtuserpass.value; if (validateuser(txtusername.value, txtuserpass.value)) { formsauthenticationticket tkt; string cookiestr; httpcookie ck; tkt = new formsauthenticationticket(1, txtusername.value, datetime.now, datetime.now.addminutes(3), chkpersistcookie.checked, username + "@ticket"); cookiestr = formsauthentication.encrypt(tkt); ck = new httpcookie(formsauthentication.formscookiename, cookiestr); if (chkpersistcookie.checked) ck.expires = tkt.expiration; ck.path = formsauthentication.formscookiepath; response.cookies.add(ck); ...

sql - Visual Studio 2010 Crashes after pasting a large multi-line string (Approximately 1500 lines) -

i creating vb application in visual studio 2010 installs sql stored procedures. these stored procedures encrypted otherwise supply clients .sql files create stored procedures. the install script creates stored procedure 1500 lines in length , has been formatted in way vs 2010 requires multi-line literals in: "first line" & _ "second line" & _ "etc..." every time paste multi-line script visual studio application crashes. have better way of assigning large string literal string variable. require following: imports system.data.sql client ... cmd cmd sqlcommand dim str string str = _ "very" & _ "long" & _ ... 1500 lines ... "string" cmd.commandtext = str or other way of assigning .sql script sqlcommand. thanks. could either paste in notepad , save there, or split in multiple strings concatenate @ end. or better, put command in resource file , load resource @ run ...

Need Onchange events for SharePoint:FormFields -

i need call javascript function when sharepoint:formfield has changed. provide client side feedback there selection. i need add on new content type form, in visual studio project. sharepoint:formfield doesn't appear have onchange event, normal asp controls. looked @ valuechanged event, looks read only. any suggestions or appreciated solution found: i resolved problem google , webborg.blogspot.com/2008/04/… , mysplist.blogspot.com/2010/03/…. add javascript should inline , after following sharepoint:formfield <table cellpadding="0" cellspacing="0" id="onetidlistform" style="width:100%"> <tr> <td width="400px" valign="top" class="ms-formbody"> <sharepoint:formfield runat="server" id="mygender" controlmode="new" fieldname="mygender" /> <sharepoint:fielddescription runat="server" id="field_mygender_d...

jquery - Railscast 197, part 2: How to remove a group of fields in Rails 3? -

i'm constructing form in rails 3, following instructions in video: http://railscasts.com/episodes/197-nested-model-form-part-2 . my form has 1 major difference form in video: instead of being able remove 1 field on form, i'd able remove group of fields form. group contains following fields: "number of people", "gender", "ethnicity", "age". able remove group of fields using checkbox in part 1 of video series, since added jquery functionality, hasn't worked. any suggestions? new.html.erb <%= f.fields_for :audiences |builder| %> <div class="audiencefields"> <%= builder.hidden_field :_destroy %> <%= link_to_function "remove", "remove_fields(this)" %> <p> <%= builder.label :number_of_people %><br /> <%= builder.text_field :number_of_people %> </p> <p> <%= builder.label :gender %><br /> <%= builder.text_field...

c# - ArgumentNullException was unhandled, out of the blue -

i have been working on project on , off, haven't touched 2 months, today came , unable run due error. ienumerable<mediatitle> query = mediatitlecollection.oftype<filmmedia>(); the debugger stops on line , gives error described in title along value cannot null. parameter name: source its frustrating since code working 100% before , dominated error. have tried clean solution without luck. enumerable.oftype raise exception if collection ( mediatitlecollection , in case) null . its frustrating since code working 100% before , dominated error. have tried clean solution without luck. you should debug application, , location mediatitlecollection supposed set. being set null or not being initialized properly.

c - data sets plots with start and end values -

Image
i trying come strategy programatically plot data sets have individual elements start , end values. give example, data set disk utilization show fragmented disk allocated chunks have bars indicated start address given allocation , end address. does gnuplot/excel provide such facility in-built plots ? regards,

Clear PowerShell overlay from Add-WindowsFeature cmdlet -

Image
i notice when creating powershell scripts use add-windowsfeature cmdlet servermanager module on windows server 2008 r2, there aqua-blue overlay not cleared until entire script finished. example, here screenshot of script uses add-windowsfeature web-server command install iis: the collecting data... start installation... overlay stays on top of console history , not disappear until after entire script finished. there way console re-paint or disable overlay? this result of write-progress called internally server manager cmdlets. if want make silent - change $progresspreference 'silentlycontinue'. you can emulate using write-progress self: for ($i = 0; $i -lt 100; $i++) { write-progress -activity "counting: $i" -status "$i" -percentcomplete $i sleep 1 } hth bartek

asp.net - Will aspx not see changes made by javascript? -

i changing contents of span javascript. can see has changed view source. when try contents in c# function right after, still has old value. my guess asp seeing html sent client, , javascript changing client html of asp cannnot see? this guess on how explain it. correct? thanks. yes, guess correct! javascript sees client side , asp.net server side. if make change on client side , want server side aware of change, can make use of ajax . see ajax more info. in .net can use webservice, controller, or page receiving ajax call.

oauth - How to use Google Drive in a Java Desktop app? -

i dealing mobile , desktop applications. trying use google drive permanent storage folder. unfortunately @ loss because cannot find examples. can point me @ example of storing or retrieving file google drive? i see simple example in code or maybe library can handle this. stuck @ retrieve , use oauth 2.0 credentials https://developers.google.com/drive/credentials did @ sample app on drive api page? edit google moved examples github

sql - How to select distinct by 2 fields -

i need able select records have isactive = 1 in addition of this: select distinct 0 communityid, case libname when 'rkhl' 'rock hill' when 'ftml' 'fort mill' when 'lanc' 'lancaster' when 'brev' 'brevard' when 'pbtc' 'midlands-clec' when 'pbti' 'midlands-ilec' end communitydesc, libname, libname + '|' filterbyid, isactive reference.dbo.community libname <> 'carotel' union select communityid, rtrim(commname) communitydesc, libname, libname + '|' + rtrim(commname) filterbyid, isactive reference.dbo.community ...

c# - MethodBase.GetCurrentMethod() reflection line explanation -

i'm transitioning c++ c# , have method call that's confusing me. think might able guess does, i'd appreciate expert telling me straight: wdresult returnvalue = (wdresult)invoke( (methodinfo)methodbase.getcurrentmethod(), new object[] { request, loadtype }); it looks me it's using reflection infoke method that's being invoked. can't understand why 1 if case though. also, why reflection instead of recursion call? note in code, different overload not being used in call. parameters request , loadtype pretty passed straight code in first line of function appears in. that's calling custom invoke() method, takes methodinfo . isn't standard reflection. look in invoke() method see why they're doing that.

proj - PHP Map projections -

i have googled myself death.. attempting write 2 php functions return x , y lat , long, in both mercator , flat non-projected (grid) maps. problem being every calculation have ran across assumes map(s) has same lat , lon @ corners, , result in meters. ugh here have .. maps of different sizes, different lat's, long's @ 4 corners. downloaded proj4 php port, 0 documentation , more code need, on whelmed ... help !! this presumes lat/long coords decimal values, , don't change direction north/south or east/west within visible range of map. if do, such values should kept single format, , made negativel (eg: 1.0 s become -1.0 n) first you'd set following variables, either finding them php or if know them in script: $width=//width of image $height=//height of image $long_at_left=//longitude of left-hand coordinates $long_at_right=//longitude of right-hand coordinates $lat_at_left=//latitude of left-hand coordinates $lat_at_right=//latitude of right-hand coo...

forms authentication - Where is ASP.NET Storing User Data? -

i'm seeing strange behavior, , i'm sure there's simple explanation don't see. using visual studio 2012 rc, mvc 4, created standard internet application (using forms authentication). used aspnet_regsql add membership tables database. updated web.config connection string point custom database: <add name="newedcoconnectionstring" connectionstring="data source=localhost\sqlexpress2012;initial catalog=newedco;integrated security=true" providername="system.data.sqlclient" /> and, of course, updated provider nodes in web.config use connection string. it works fine. can launch application in usual iis express, register user, login user, etc. kill application, re-launch, , can still login user. it's persisting data. however, in sql server management studio when select * from of aspnet_* tables, don't contain data. where persisting data? it turned out @aristos alluded in comments on question above. was u...

symfony - Symfony2/Doctrine manyToOne-relationship does not appear in tables -

i'm working doctrine schema, ran trouble because 1 of manytoone-relationships won't persist in database. clueless why case, because eye, syntax looks correct. can identify problem? below schema in yaml. there no tables relating these 2 entities in mysql-database after running php app\console doctrine:schema:update --force . me\mybundle\entity\freetextfield: type: entity table: null fields: id: type: integer id: true generator: strategy: auto name: type: string flagprivate: type: boolean description: type: text nullable: true onetomany: entries: targetentity: freetextentry mappedby: xfield lifecyclecallbacks: { } me\mybundle\entity\freetextentry: type: entity table: null fields: id: type: integer id: true generator: strategy: auto content: type: text manytoone: xfield: targetentity: freetextfield inversedby: en...

mySQL & PHP Looping -

Image
i have been given access third parties database , wish create tool using information. database designed original purpose very large , segregated. need complete following task: from the below schema, need complete following tasks: look item in invtypes, check both invtypematerials , ramtyperequirements see if materials need build item. if yes, each of materials in invtypes, , again repeat process see if in turn need components. loop keeps going until the check on both invtypematerials , ramtyperequirements false, can 5 or 6 loops, 5 or 6 items per loop check 1561 loops assuming 1 loop original item, 5 loops per material of there 5, 5 times. now tried complete code , came follow: $materiallist = array(); function getlist($dbc, $item) { global $materiallist; // obtain initial material list $materials = materiallist($dbc, $item); // each row in database while ($material == mysqli_fetch_array($materials)) { // check if there sub materials require...

perl cookies wrong time -

so creating cookies using perl's cgi module, , so: my $cookie = cgi::cookie->new(-name => "$name", -value => "$val", -expires => "$expiration_date", -path => $cookie_path, -secure => 0 ); print "set-cookie: $cookie\n"; and cookie set in browser, issue time not match expiration date put. example, if put +1d expiration date, +1d - several hours. checked system time see if issue, system time right. printed out cookie , got this: actual time of cookie creation: 6/4/2012 12:10:02 pm cookie: session_id=534fec49c864d8cf0325779b0921b6be1338829802484; path=/; expires=tue, 05-jun-2012 17:10:02 gmt the strage thing above record actual time of cookie creation perl's 'localtime(time())' function, records different time date command puts out (so not actual current time)! , e...

ios5 - Swiping from 1st ViewController to the 2nd ViewController,and then back to the first, unloads a loaded image to blank in the first one in iOS 5 -

i'm starting out in ios app development,so if question seems foolish please bear me. i'm creating sample app have 2 view controllers.the first 1 has full screen image,with navigation bar , camera roll button, use pick image galley when app starts.then swipe second view controller enter data clicked it,what camera used etc in text box.the second view controller has navigation bar , button item in navigation bar named return 1st view controller image.i have linked button via segue 1st view controller.now setup functional,but problem when load image gallery , swipe second view write data,and hit button return first view, image loaded gallery no longer there , i'm presented blank screen. so how can make sure don't loose loaded image when swipe second view controller first one? thanks appreciated. the problem control dragged button of second view first view right? doesn't "move" viewcontroller, "creates" new viewcontroller of first ty...

.net - How do I place resources inside the .EXE? -

the "standard" way have language specific resources in .net have folder under .exe each language , in folder have file filename.resources.dll. leads lot of folders on place under every directory have .exe in has been localized. is there way place these resources inside .exe? thanks - dave i assume you're not happy app being monolingual (in case can embed resources in assembly). the localization model provided .net framework depends on file structure describe. answer question, can't. of course can keep assemblies in 1 folder, means you'll have 1 language subfolder per language. you try , build custom resource manager , use resources embedded in assemblies, think complicate process lot (for example you'd have rebuild , redeploy if add language or change 1 translation, , managing translations real pain if merged together).

file - Use external XTemplate in Sencha Touch 2 -

i need use external file content xtemplate. basically, want use external file no "strange" solution, use "xtemplate.from", or put xtemplate objects in variables. this: list.html <div>name: #{object.name} </div> file.js ... content = ext.create('ext.panel.panel', { fullscreen: true, scroll: 'vertical', data : planetearth, tpl: "index.html" }); ... basically, once define file tpl, should compiled automatically. any idea? thanks! it seems article guides want do: http://www.sencha.com/learn/xtemplates-part-ii/

javascript - Three.js: Plane visible only half the time -

i've created plane, rotate, using three.js. reason, plane doesn't show half time. i've created fiddle here showing behaviour. note has changed in three.js revision r50. rendering both sides of plane can achieved through side property on material, i.e. plane.material.side = three.doubleside; look here more details.

Google BigQuery worked for me without billing until Yesterday. Was i just lucky so far? -

i have been using google bigquery without billing enabled until yesterday past 3 weeks (until jun 4th australian time). today gives me error stating "you have enable billing". my question : was got lucky far? or changed ?. i started using browser tool public data created few tables , worked , started using command line tool yesterday , today gave me error. anybody faced similar issue ? google bigquery premium service, , started billing on june 1, 2012. sent reminder on our bigquery-announce mailing list (which list subscribe announcements new features) here same information: the bigquery api allows 100gb/mo of free query processing. after exceeding free tier of query processing, project must signed billing. see our pricing page more details. required able load data system. if haven't activated billing on project, , exceed free quota, bigquery api return 403 "billingnotenabled" error message: "billing has not been enabled project....

python - User defined http status code on Google App Engine -

i have following handler gets content received request: class dummyhandler(webapp2.requesthandler): def get(self): try: msg = cgi.escape(self.request.get('content')) if msg none: raise illegalcontent except illegalcontent ex: logging.error("illegal content received") self.error(requesterrorcodes.illegal_content) except exception ex: logging.error(ex) self.error(requesterrorcodes.unexpected_error) when run unittest, following error: self.error(requesterrorcodes.unexpected_error) file "/applications/googleappenginelauncher.app/contents/resources/googleappengine-default.bundle/contents/resources/google_appengine/lib/webapp2/webapp2.py", line 582, in error self.response.status = code attributeerror: can't set attribute i need define user specific error codes in http response client handle. supported in google app engine...

javascript - Textarea in IE8 Newline issue -

i'm making cross-browser form, requires textarea. textarea receives data 2 ways: - sending ajax call server , returning data - user inputted data http://jsfiddle.net/garrettwong/x3ksp/ i'm having issue on ie8 textarea text not formatted (newlines not being read), in chrome, same code, nicely formats textarea. i'm hoping use solely javascript solution if possible, i'm not sure go here. why using text() ? set value using val() . new lines \n\r .

jquery - Picture rotates behind the screen, 1px issue -

hello i'm having issues slider : http://www.unscspartanteamomega.com/home2 when open site on google chrome dev tools see issue comes <div id="featured" class="orbit" style="width: 1px; height: 370px; "> the 1px blocking picture , i've checked css , there nothing, don't know how rid of 1px. can point me or me out? your div id "featured" has style width:1px; edit: sorry forgot say, not in css inline style or added dynamically javascript. check html source , remove style="width:1px;" on div or specify right dimension. btw. if don't have suggest install firebug, save time , nerves!

sql - MySQL special ORDER BY -

suppose have following table name | genre --------------------- book 1 | scifi book 2 | horror book 3 | scifi book 4 | romance book 5 | horror how can sort table above "genre" in sql following results. please note order. it's h s r, , not h r s. possible achieve without using union ? name | genre ------------------------ book 2 | horror book 5 | horror book 1 | scifi book 3 | scifi book 4 | romance edit: there 3 genres. you use field function customise sort order select * `table` order field(`genre`, 'horror', 'scifi', 'horror'), `name`;

python - ctypes cdecl gives 4 bytes missing when calling gcc compiled dll returning a struct -

i have c library (chipmunk) want call using ctypes. however, fails on functions return struct? the error file "qw.py", line 19, in <module> b = cpbbnew3(1,2,3,4) valueerror: procedure called not enough arguments (4 bytes missing) or wrong calling convention this (relevant) c-code: in cpbb.h typedef struct cpbb { cpfloat l, b, r ,t; } cpbb; cpbb cpbbnew3(cpfloat l, cpfloat b, cpfloat r, cpfloat t); in cpbb.c cpbb cpbbnew3(cpfloat l, cpfloat b, cpfloat r, cpfloat t) { cpbb bb = {l, b, r, t}; return bb; } compiled gcc -o3 -std=gnu99 -shared -c gcc -o3 -std=gnu99 -shared -s then python looks from ctypes import * chipmunk_lib = cdll.loadlibrary('''c:/code/pymunk/trunk/pymunk/chipmunk.dll''') class cpbb(structure): pass cpbb._pack_ = 4 cpbb._fields_ = [ ('l', c_double), ('b', c_double), ('r', c_double), ('t', c_double), ] cpbbnew3 = chipmunk_lib.cpbbnew...

Random sampling of two vectors, finding mean of sample, then making a matrix in R? -

thanks time! my data frame simple. 2 columns: first has genotype (1-39) , second has trait values (numerical, continuous). choose 8 genotypes , calculate mean , stdev of associated trait values. in end sample 8 genotypes 10,000 times , each sample have stdev , mean of associated trait values. ideally in matrix each row represented sample, 8 columns each genotype, , 2 final columns stdev , mean of trait values associated genotypes. oriented other way too. how sample 2 different columns in data frame both values show in new sample? i.e genotypes , trait values mean , stdev calculated how sample matrix i've described above? how repeat process 10,000 times? thanks again! this return single sample of rows genotype in random sample of 8 traits: dat[ dat$genotype %in% sample(1:39, 8), ] the replicate function designed repeat random process. repeat 3 times getting sd of "trait" such sample of 2 genotypes: dat <- data.frame(genotype=sample(1:5, 2...

Format currency using javascript -

a script returns either number 0.0580 in x.xxxx format or (x) x units left. i want format number 0.0580 , return 5.8 cent or return x units left . any ideas how in javascript? how format x.xxxx? in case first x not 0 want return e.g. 1.75$. ms has written nice plugin jquery. it's useful if you're localizing. give go: http://weblogs.asp.net/scottgu/archive/2010/06/10/jquery-globalization-plugin-from-microsoft.aspx i'm not sure if can used outside of jquery...

ruby on rails 3 - how to write search method code to search more than one id at a time -

in project trying display products based on user choice. user can check department(women, men , kids) , category (dress, tops, tees etc) wish see. using check box. if user checks(selects) women departments products belongs women displayed. if user checks(selects) both women department , dress category products belongs both women department , dress category displayed. if user selects both women , men departments , shoes category products belongs women , men department , shoes category displayed. achieve using solr (sunspot gem). question can pass multiple ids department_id , category_id @ same time. for example possible @search_res=productdetail.search :department_id, 1,2,3 :category_id, 1,2,3,4, etc (may present or absent) end if possible please tell me how do? please give me syntax? please me. update thank salil answer, department id , category id's not static in case. came when user selects @ runtime. means category_id , departmen...

c++ - C: Using functions from files within in the same project -

my question not link direct example, more of question whole. when coding c++, found (after looking through threads) in order use functions different files in same project, either need header file. so, example, if have main function in file called "main.cpp" , wanted use function, "prob1()" in file called "problem1.cpp", need use header file. what confusing me why not have worry programming in c? when programming in c, in order use functions different files, call function directly. any help/explanation appreciated. thanks! your c compiler can implicitly declare function, should doing yourself. if turn warnings, you'll see like: file1.c: warning: implicit declaration of function ‘func_from_f2’ when file1.c being compiled , implicit declaration used create object file , when linking have hope function exist , declaration correct object files can linked successfully. if not, linker give error somewhere along lines of: undefi...

.net - How to make a method run on startup in C# -

i'm trying make method draws background of picture box when first open application. there way this? i have tried private void form1_load(object sender, eventargs e) { drawbackground(); } public void drawbackground() { graphics simwindow = pictureboxsimdisplay.creategraphics(); solidbrush brush = new solidbrush(color.green); simwindow.fillrectangle(brush, 0, 211, 491,5); } but not working. i override forms onpaint method, way background you draw on redrawn when ever form repainted including initial load, if adding image or bitmap should use form load event others have stated. from above link: the onpaint method overridden repaint image each time form painted; otherwise image persist until next repainting . give try. found using onpaint method little erratic on initial load, if use timer(100ms) invalidate form works fine every time. protected override void onpaint(painteventargs e) { ...

java - nested forEach loop JSTL issue -

i'm making calendar using jstl , ran issue there can more 1 item per day.... i'm attempting use nested foreach loop work out there duplicate data occurring because of nested foreach loop. here code: <div id="calendar_item_meta"> <c:foreach var="calendaritemmeta" items="${inboxcalendar.mapcalendar}" varstatus="status"> <c:set var="calendaritemcounts" value="${fn:length(calendaritemmeta.value[0].mailitemspayable)}"/> <c:set var="calendarmappingmemoholder" value="${calendaritemmeta.value[0].mailitemspayable[status.index].billinfo.memo}"/> <c:set var="calendarmappingamountholder" value="${calendaritemmeta.value[0].amount}"/> <div id="item_${calendaritemmeta.key}"> <c:if test="${calendaritemcounts > 0}"> ...

objective c - How to know when a job that require multiple threading has finished? -

one thing is: -(void)grabbingprocess:(void (^)())block; { self.othergrabbingindicator +=1; block(); dispatch_after(dispatch_time(dispatch_time_now, 2 * nsec_per_sec), dispatch_get_current_queue(), ^{ self.othergrabbingindicator -=1; }); } everytime want run may take long time in background, [grabclass grab] grabbingprocess: ^{ //do grab data etc. }]; there many such functions , many such data. example, @ first grab businesses id. grab details on businesses on separate thread. i want know time when threads have finished , post suitable notification. the problem solution after while, quite value of self.othergrabbingindicator hover around 2 or 3 never going down though of thread have finished. somehow of self.othergrabbingindicator +=1; "leaked" , not matched self.othergrabbingindicator -=1. wonder how can leak ever happen? if want run blocks asynchronously , find out when they're done, appropriate tool dispatch_group . can...

Switch branches with default branch in mercurial -

Image
in repo i'm working, created named branch @ time try different approach in issue. continued work in default branch well. now named branch has matured speak, make branch, default one, , give different name (old) default branch. is possible? i've found question, mercurial: can rename branch? , can rename default branch successfully, afterwards when try rename named branch default, fails error abort: branch of same name exists yes, can. you need close branches , give them required name ps: seems needed add -f flag branch command sample scenario hg init echo "123" > file hg addremove hg commit -m "init default" hg branch new echo "new" >> file hg commit -m "init new" hg default echo "default" >> file hg commit -m "default 2nd" hg commit --close-branch -m "close default" hg new hg commit --close-branch -m "close new" hg branches # none hg log # see upda...