Posts

Showing posts from June, 2013

magento - How to get the base url of a specific store view in a static block? -

i know in .phtml file example: <?php echo $this->helper('derco_core')->getstoreurl('dcmotosesp')?> i want same thing inside static block. in advance. there no 'clean' way of getting url specific store using shortcodes ( {{store url}} ). ...because store shortcode handler end (see mage_core_model_email_template_filter::storedirective() ): return mage::app()->getstore(mage::getdesign()->getstore())->geturl($path, $params); this means store cannot passed parameter. the following might work it's bit ugly. idea send parameter ___store through $_get telling magento switch specific store. <a href="{{store url="some/url/here" _query="___store=store_code_here"}}">test link</a> (replace 'store_code_here' specific store code). an other option extend method mentioned above , allow receive store_code parameter.

c - How Callback is maintained from Userspace to Kernel Space -

i learning driver , looking watchdog driver code value being written /sys/devices/virtual/wdc_per guess logic how driver gets value userspace , exposed file in user space "sys/devices/virtual/wdc_per" but how value wdc_per reached driver, there must callback maintained in case gpio based watchdog driver , gpio_wdt.c may having callback. but not figure out how happens anybody can me find out userspace kernel space link. first of all, driver, gpio_wdt.c , doesn't seem exist in mainline kernel of date, it's hard comment it. sysfs (usually mounted @ /sys ) easy use. this great example of how create sysfs attributes. basically, create attributes (will become sysfs file names) , register them 2 defined operations (callbacks): store , show , equivalent of resp. write , read . show callback called everytime sysfs file (attribute) read , store when it's written. when writing device driver belongs existing class (most situation), need you

search - how to configure the synonyms_path in elasticsearch -

i'm pretty new elasticsearch , want use synonyms, added these lines in configuration file: index : analysis : analyzer : synonym : type : custom tokenizer : whitespace filter : [synonym] filter : synonym : type : synonym synonyms_path: synonyms.txt then created index test: "mappings" : { "test" : { "properties" : { "text_1" : { "type" : "string", "analyzer" : "synonym" }, "text_2" : { "search_analyzer" : "standard", "index_analyzer" : "synonym", "type" : "string" }, "text_3" : { "type" : "string", "analyzer" : "synonym" }

javascript - How to create custom button Ask seller Ebay -

i creating new custom selling page shop , create button: "ask seller question". have been googling around, unfortunately, couldn't find it. can please share advice? 1 thing found may work: script; honest (as beginner), not sure how link button. <script language="javascript"> (i = 0; < document.links.length; i++) { if (document.links[i].search.indexof("showcoreasksellerquestion") > 0) { document.write('<a href="'+document.links[i].href+'" title="ask question">ask seller question</a>'); break; } } </script> the javascript have work, show link. make button need add css. here can read on how works. css tell html, or in case <a> how look. give tag an id <a id="some-name"> in css this: #some-name{ background: url("yourimagepath") no-repeat; height: [the height in pixels of image] } this easiest thing fi

Apache Felix - Storing bundles in the assests directory of android application -

i embedding apache felix android app. right now, use following code install bundle: imagebundle = bundlecontext1.installbundle("file:sdcard/download/androidimageviewer_1.0.0.201308221559.jar"); this works ok, requires bundle stored in sdcard of android device. however, don't that. want bundle stored in directory inside android project. example, inside assests folder. there way achieve this? i tried this: imagebundle = bundlecontext1.installbundle("file:assets/bundles/androidimageviewer_1.0.0.201308221559.jar"); and expected, didn't work. the url wrong. correct url like file:///android_asset/androidimageviewer_1.0.0.201308221559.jar as pointed out here .

c# - How to enable button if item selected in a GridView -

i want enable button when grid view item selected update gui in metro apps. button include list view item. below code snippet of want do. please help. <gridview name="searchpanelgrid" selectionmode="single" horizontalalignment="left" scrollviewer.ishorizontalscrollchainingenabled="true" scrollviewer.isverticalscrollchainingenabled ="true" scrollviewer.horizontalscrollbarvisibility="auto" scrollviewer.verticalscrollbarvisibility="auto" scrollviewer.horizontalscrollmode="enabled" scrollviewer.verticalscrollmode="enabled" itemssource="{binding source={staticresource collectionitems}}" grid.row="2"> <gridv

java - Issue about Jsoup - fetch sub url but show main url -

i use jsoup fetch http://live.wallstreetcn.com/ in android. however, shows context of main url http://wallstreetcn.com/ . why that? doc = jsoup.parse(new url("http://live.wallstreetcn.com"), 10000); list<map<string, string>> list = new arraylist<map<string, string>>(); elements es = doc.getelementsbytag("div"); log.e("", "es:" + es);

Taking in unique inputs in a struct array in C -

i writing program create structure named 'student'. need input various data particular student. here program till now. #include<stdio.h> #include<stdlib.h> struct student { char* name; int id; float marks_1; float marks_2; }; void main() { int num, var_i, var_j, var_k, var_l, duplicated_id = 0; printf("enter number of students\n"); scanf("%d", &num); struct student s[num]; printf("enter data students\n"); (var_i = 0; var_i < num; var_i++) { var_j = var_i + 1; printf("enter name of student_%d\n", var_j); scanf(" %[^\n]%*c", &s[var_i].name); printf("enter id of student_%d\n", var_j); scanf("%d", &s[var_i].id); (var_k = 0; var_k < var_i; var_k++) { if (s[var_k].id == s[var_i].id) { printf("duplicate id, program exit"); return; } } printf("enter marks(sub_1) of student_

android -notlong eclipse: "Invalid resource directory name" -

i try refactor/rename layout/large forlder to layout-xlarge-mdpi-notlong then eclipse return error invalid resource directory name i don't understand why. res/layout/my_layout.xml // layout normal screen size ("default") res/layout-small/my_layout.xml // layout small screen size res/layout-large/my_layout.xml // layout large screen size res/layout-xlarge/my_layout.xml // layout large screen size res/layout-xlarge-land/my_layout.xml // layout large in landscape orientation res/drawable-mdpi/my_icon.png // bitmap medium density res/drawable-hdpi/my_icon.png // bitmap high density res/drawable-xhdpi/my_icon.png // bitmap high density supporting multiple screens because -mdpi-notlong not supported in android.

antlr - ANTLR4 parsing error: no viable alternative at input -

i have grammar erroneous parsing simple file generates strange error messages. i simplified following grammar as without altering error (if remove 'this' tree gui output of antlrworks colors token int of sample file differently although structure seems equal). grammar depclsj_no_java_debug; module : ( methoddecl )* ; methoddecl : pathtype identifier '()' block ; pathtype : identifier | 'this' ; block : '{' ( localdecl ';' )* ( statement )* ( expr )? '}' ; localdecl : pathtype identifier ( '=' expr )?; statement : block | expr ';' ; expr : dotexpr ( '=' dotexpr )* ; dotexpr : identifier ( '.' identifier )* ; identifier : ('a'..'z'|'a'..'z'|'_') ('a'..'z'|'a'..'z'|'0'..'9'|'_')* ; demo code: void main() { = c; int b; } antlrworks 2 gives me

php - mysql phpmyadmin User Input COMPARE database -

hi guys i'm new php , mysql, trying check user input &username if there's existing same username in database, , same user input $email. i have below codes, tried having line echoes , compares user input against fetch rows/ data database. able verify reaches point line echo $email."compare".$result2; both same, yet passes condition $email == $result2 result2 email fetch database. can please point me what's wrong? in advance. $extract= mysql_query("select * users"); $resultq = mysql_num_rows($extract); while($row= mysql_fetch_array($extract)) { $result = $row['username']; $result2 = $row['email']; echo $email."compare".$result2; if($username == $result) { echo "<script type=\"text/javascript\">alert('username taken')</script>"; echo "<meta http-equiv=\"refresh\" content=\"0;url=6signup.html\" />";

plot - R: how to set even space on a scale bar -

Image
i need plot map of global runoff. i'd see more details @ smaller quantities on scale bar. right can see color scheme @ 0-500 congested , hard see. there way can set space of 0-50,50-100, 100-200, 200-300, 300-400, 400-500, 500-1000,1000-2000 on scale bar? here's example library(raster) library(rastervis) library(lattice) a1<-c(1,2,-4,100,250,500,-50,20,400,1000,1900,-1500,15,150,600,-850,8,-65,43,900,25,350,600,-550,45) matrixa1<-matrix(a1,5,5) rastera1<-raster(matrixa1) sbreak<-c(-2000,-1000,-500,-400,-300,-200,-100,-50,0,50,100,200,300,400,500,1000,2000) col.l <- colorramppalette(c('darkblue','blue4','blue3','blue1','blue','deepskyblue','cyan','grey70','grey88','yellow1','orange', 'darkorange1','darkorange2','red','red3','darkred'))(100) print(levelplot(rastera1,margin=false,col.regions=col.l,main="

vba - Unable to get PivotFields property of the PivotTable class -

i'm trying make macro changes filters of several pivottables (not all), i'm getting error on pivotfields, here's sample of code: sheets("sheet1").pivottables("pivottable" & pivot_counter).pivotfields( _ "[year].[year].[year]").visibleitemlist = array("") my questions are: 1- why use pivotfields("[year].[year].[year]") when using visibleitemlist? why have repeat , what's meaning of it, couldn't anywhere. 2- supposedly wrong code? pivot table has field called "year" , filter set specific year (let's 2013) , wanted change possible years. sub tester() showall activesheet.pivottables("pivottable1").pivotfields("year") end sub sub showall(pf pivotfield) dim pi pivotitem application.screenupdating = false each pi in pf.pivotitems pi.visible = true next pi application.screenupdating = true end sub

Android SharedPreferences to getInt -

i using sharedpreferences "age" encounters following error...how handled?? thanks! sharedpreferences settings3 = profile.this.getsharedpreferences("myapp",0); age = settings3.getint("age",25); textview_age_input.settext(""+age); //line 122 logcat: 08-24 01:23:59.588: e/androidruntime(15117): caused by: android.content.res.resources$notfoundexception: string resource id #0xa0 08-24 01:23:59.588: e/androidruntime(15117): @ android.content.res.resources.gettext(resources.java:242) 08-24 01:23:59.588: e/androidruntime(15117): @ android.widget.textview.settext(textview.java:3806) 08-24 01:23:59.588: e/androidruntime(15117): @ com.abc.abc.profile.oncreate(profile.java:122) 08-24 01:23:59.588: e/androidruntime(15117): @ android.app.activity.performcreate(activity.java:5206)

What classifies as a recursive function in Java -

does count recursive function...if no, reason. changes classify such...thanks public class recursion { public static void recursionfunc(int beginning_value){ if (beginning_value != 0){ system.out.println(beginning_value); recursionfunc(beginning_value - 1); } } public static void main(string[] args){ recursionfunc(10); } } a function calls itself, directly or indirectly, called recursive . function calls itself, recursive. here example of recursive functions calls indirectly: static void funca(int x) { if (x <= 0) return; if (x % 2 == 0) { funcb(x-1); } else { funcc(x-1); } } static void funcb(int x) { funca(x-1); } static void funcc(int x) { funca(x-2); }

data analysis - How to Find difference between two values of last two dates in R program -

df2 date emmi act no2 2011/02/12 12345 21 11 2011/02/14 43211 22 12 2011/02/19 12345 21 13 2011/02/23 43211 13 12 2011/02/23 56341 13 12 2011/03/03 56431 18 20 i need find difference between 2 dates in column. example difference between act column values.for example, emmi 12345, difference between dates 2011/02/19 - 2011/02/12 = 21-21 = 0. want entire column of act. add new column diff , add values that. can let me know please how it. this output want df3 date emmi act no2 difact 2011/02/12 12345 21 11 na 2011/02/14 43211 22 12 na 2011/02/19 12345 21 13 0 2011/02/23 43211 13 12 -9 2011/02/23 56341 13 12 5 try this: df3 <- df2 df3$difact <- ave( df3$act, df3$emmi, fun= function(x) c(na, diff(x)) ) as long dates sorted (within emmi) work, if not sorted need modify above sort w

asp.net mvc - DataFormatString for DateTime -

i'm trying apply format in datetime attribute not working. have this: [datatype(datatype.date)] [displayformat(dataformatstring = "dd/mm/yyyy", applyformatineditmode = true)] public datetime datainscricao { get; set; } i've tried in many ways (changing dataformatstring) none of them working. i'm using datepicker date fields. i tried apply format jquery: $("#datainscricao").datepicker( {dateformat: 'dd-mm-yy'}); it works, format applied in textbox when try save date format lost. if enter date 12/01/2013, changes 01/01/0001. in gridview format different (mm-dd-yyyy) , mask of textbox working wrong. i don't know make work. there can me issue? thanks! update this method in controller returns entity edit. public actionresult editar(int id) { var agendamento = _repository.getsingle(a => a.id == id); return view("criar", agendamento); } and view: @model pncq2013.domain.entities.agendamentomanutencao @

java - Is hashMap implemented as an array of linked lists -

while reading hashmap see implemented array of buckets? these buckets linked lists? if so, why called buckets , not linked lists? looking @ source code of hashmap tells it's implemented array of entries: transient entry[] table; each entry has field next , create single linked list structure: static class entry<k,v> implements map.entry<k,v> { final k key; v value; entry<k,v> next; "bucket" higher-level term, using in literature , when explaining hash maps. here "buckets" implemented single linked lists.

inversion of control - How to use Unity's injectionfactory for child containers in ninject? -

i stuck ninjects equivalent unity registration: var container = new unitycontainer(); container.registertype<myfactory>(new containercontrolledlifetimemanager()); // resolve instances once per child container myfactory container.registertype<imyinstance>(new hierarchicallifetimemanager(), new injectionfactory(c => c.resolve<myfactory>().getmyinstance())); already tried without effect: var kernel = new standardkernel(); kernel.bind<myfactory>().toself().insingletonscope(); // context preserving should job child containers, right? // thought in call scope ist equivalent unity's hierarchical lifetime manager? kernel.bind<imyinstance>().tomethod(ctx => ctx.contextpreservingget<myfactory>().getmyinstance()) .incallscope();

How do I change or add an additional HTML Publishing Template in Flash CS6? -

how update or add additional html template in flash professional cs6? have tried instructions in http://adobe.ly/ucpsvf , neither changes existing templates or new templates appear in application. the adobe site wrong (at least mac version). "customize html publishing templates" portion lies : /applications/adobe flash cs5/ language /first run/html you want poking around in: ~/library/application support/adobe/flash cs6/*en_us*/configuration/html/

javascript - How to move table to the top of the DIV container based on a Condition with JQuery? -

i have multiple tables stacked inside div container below:- <div id="mycontent" style="display: block;"> <table id="mytable" cellspacing="0" cellpadding="0" > <tbody> <tr> <td style="padding-top: 10px;"> <table> <tbody> <tr> <td align="left"> health care </td> </tr> <tr> <td align="left"> 20 wisconsin ave</td> </tr> <tr> <td align="left"> 641.235.5900 </td> </tr> <tr> <td align="left">

WPF DataGrid Binding List of Object that contains Dictionary<string,string> in XAML -

i'm trying figure out how display data dictionary property of list inside wpf datagrid gridviewcolumn all examples find appear map list of simple entities can . traversed {binding answers.title} . mine more {binding answers["title"]} doesn't work in xaml i'm missing obvious here. ideas? edit: list contains entity contains dictionary. answers dictionary in entity. if understand correctly, have dictionary datacontext, , need display either key or value listboxitem. can try following : here data dictionary can change displaymemberpath="key", if need display key. can used display data property while complex object in datacontext.

xaml - How to decrease line height -

i'm trying reduce line spacing decrease lineheight. less default not become. <textblock style="{staticresource font36}" lineheight="6">list<linebreak/>with parameters</textblock> try change linestackingstrategy blocklineheight or baselinetobaseline , so: <textblock style="{staticresource font36}" linestackingstrategy="blocklineheight" lineheight="6" >list<linebreak/>with parameters</textblock> more info line stacking strategy here: what line stacking strategy in silverlight textblock control?

html - DIV inline-block not aligning horizontally -

i have 5 columns aligned using display:inline-block works fine, there 1 problem. when refresh page 4 or 5 times while first column on top other 4 columns go bottom of , when refresh again gets original place. couldn't figure out causing , content inside columns coming database. can give me hint? css .col1 { display:inline-block; vertical-align:top; width:225px; } .col2 { display:inline-block; vertical-align:top; width:225px; } .col3 { display:inline-block; vertical-align:top; width:225px; } .col4 { display:inline-block; vertical-align:top; width:225px; } .col5 { display:inline-block; vertical-align:top; width:225px; } .col_content_wrap { background-color:#fff; border:1px solid #ddd; border-radius:5px 5px 5px 5px; box-shadow:4px 4px 1px #eee; margin-bottom:10px; } .imgwrap { height:169px; position:relative; width:223px; } .price_wrap { border-top:1px solid silver;

php - Laravel 4 form data submit and update the database and also send an email with the help of post data -

i have form 3 text fields , have submit form can retrieve form post data , send mail recipients. need store post value in variable , can use these variables update database , sending email data. i'm getting error symfony \ component \ httpkernel \ exception \ methodnotallowedhttpexception routes.php: <?php route::get('mail,new',array('as' => 'new_mail' , 'uses' => 'sendmail@new' )); route::post('formtest/submit','sendmail@create'); route::get('sendmail', function(){ $data = array('detail' => 'email' ); $body = 'body here'; $recipients = 'abc@a.com,def@xyz.com'; $subject = 'test mail'; $date = new datetime(); $d = $date->format('u = y-m-d h:i:s'); mail::queue('emails.sendmail', $data, function($message) { $message->to('abc@ymail.com',

directive - AngularJS DOM selection inside tabset -

i'm bit of angular newbie, have run seems pretty dumb problem. i've created directive requires me find specific dom element. works nice , good, except once place directive inside bootstrap ui tabset, bad things happen. think since tabset directive uses custom html elements (i.e. , dom selection no longer works. i've tried using jquery selector, fails. here's simplified version of code: --html <body ng-controller="maincontroller"> <tabset> <tab heading="title 1"> <my-directive id="mywidget"></my-directive> </tab> </tabset </body> --js app.directive('registrationgrid', function() { return { restrict: 'e', link: function($scope, element, attrs) { var element = document.getelementbyid("mywidget"); //do stuff here } }) there has easy way around this, i'm @ loss. i'm tempted update tabs directive work off of attrib

command prompt - Reading from a text file in java is returning some garbage value -

i'm performing commands through command prompt , storing values in text file. wmic logicaldisk drivetype=3 deviceid > drive.txt now want read string stored in text file java file. when try this: try { file file = new file("drive.txt"); filereader reader = new filereader(file); bufferedreader in = new bufferedreader(reader); int i=0; while ((string[i] = in.readline()) != null) { system.out.println(string[i]); ++i; } in.close(); } catch (ioexception e) { e.printstacktrace(); } i output follows: ÿþd[]e[]v[]i[]c[]e[] how avoid this? while ((string[i] = in.readline()) != null) { system.out.println(string[2]); } over there missing i++; however advise use structure: use arraylist instead of array, since allows have self-resizing structure, instead in wh

Java switch user using su on linux -

i writing java program dor oracle ebs needs switch user because of specific permissions defined on user different applmgr. approach we're taking have java class switch user on separate session , list file folder new user has access. any options available? so far create 2 shell script files , run these shell scripts, 1 store environment variables , other 1 switch user , list files. appreciate help. you change group permissions on file. start system.process( "su user && cat file" ); have other user copy file using cronjob...

perl - How do I use the data from a YAML file after reading it? -

i reading data in yaml file (use yaml qw/loadfile/). need able read values , insert them other files. the yaml file in format: --- host: - name: first_host interface: - name: eth0 oldip: 1.2.3.4 newip: 2.3.4.5 oldgw: 1.2.3.1 newgw: 2.3.4.1 - name: eth1 oldip: 1.2.3.4 newip: 2.3.4.5 oldgw: 1.2.3.1 newgw: 2.3.4.1 - name: eth2 oldip: 1.2.3.4 newip: 2.3.4.5 oldgw: 1.2.3.1 newgw: 2.3.4.1 if run through data::dumper following ($data::dumper::terse enabled): { 'host' => [ { 'interface' => [ { 'oldgw' => '1.2.3.1', 'newgw' => '2.3.4.1', 'name' => 'eth0', 'newip' => '2.3.4.5',

html - How do I place an iframe and a div side by side? -

beginner htmler here. trying edit churches website. use dacast stream , chatwing 1 on top of over i want place them side side. help. you need use css in order correctly. if unfamiliar css beginner, must effective. in html: <div id="wrapper"> <div>content</div> <iframe src="urlhere"></iframe> </div> and css: #wrapper div, iframe { float: left; } but if cannot use css, can use table. method not recommended. <table> <tr> <td><div>content</div></td> <td><iframe src="dacast"></iframe></td> </tr> </table>

Configure LDAP certificate dir in PHP 5.5.x (Windows) -

until version 5.4, when php compiled source, ldap extension hard coded certificates in c:\openldap\sysconf folder. since 5.5, 'harcode' replace environment variable called %sysconfdir%. can't make ldap extension point same dir did before, no matter do! :( in php 5.4, ldap_config.h #define ldap_sysconfdir "c:\\openldap\\sysconf" in php 5.5, ldap_config.h #define ldap_sysconfdir "%sysconfdir%" sorry bad english. clue? thanks. download latest version of php 5.5. this has been resolved in php 5.5.4 binaries windows.php.net. ldap extension looks " c:\openldap\sysconf\ldap.conf " had done in 5.4.

ruby on rails - Returning count of child in json.rabl -

i have location model render in json format using rabl. index.json.rabl looks way : object false collection @locations attributes :id, :name, :address, :rating :rating integer calculated records in rating model (a location has_many rating , rating belongs_to location ). retrieve in rabl file number of line of rating model used calculate value. i tried : child :ratings attributes :count end and node(:ratings_count) { |m| @ratings.count } but doesn't work... me there ? thanks ! if don't misunderstand mean. think want use rating.count in rabl. you have closed answer using "node". node(:ratings_count) { |l| l.ratings.count } in block of node, local variable "l" 1 object of collection above.

javascript - Uncaught ReferenceError: y is not defined -

it seems not checkboxes being checked saved values. looks overlooked item.appointmenttype[1] array of values , checkboxes[i].value string, , if statement never true. think nested loop necessary loop through item.appointmenttype[1]. should able use if statement compare checkboxes[i].value item.appointmentvalue[1][y] example. however, i'm not sure if code have written correct. can me rewrite work rest of code? var checkboxes = document.forms[0].appointmenttype; for(var i=0; i<checkboxes.length; i++){ if(checkboxes[i].value === item.appointmenttype[1]){ checkboxes[i].setattribute("checked", "checked"); } for(var ii=0; ii<item.appointmenttype.length; ii++){ if(checkboxes[i].value === item.appointmenttype[1][y]){ checkboxes[y].setattribute("checked", "checked"); } } }

c++ - Storing an array in a separate class file -

i coding ludum dare right , trying make separate class give me array return type of function. have array set up, can't figure out how make return type array can use in main function. how go returning array , setting variable in main.cpp array? here couple of examples, each own advantages: #include <iostream> // c++11 #include <array> #include <vector> void myvectorfunc1(std::vector<int>& data) { (unsigned = 0; < data.size(); ++i) data[i] = 9; data.push_back(1); data.push_back(2); data.push_back(3); } std::vector<int> myvectorfunc2(void) { std::vector<int> data; data.push_back(1); data.push_back(2); data.push_back(3); return data; } /* c++ 11 template<std::size_t s> void myarrayfunc1(std::array<int, s>& arr) { (auto = arr.begin(); != arr.end(); ++it) *it = 9; } std::array<int,5> myarrayfunc2(void) { std::array<int,5> myarray = { 0, 1

android - Main Layout visibile when showing popup -

my app shows small popup window animated gif when run it. problem main layout(blank) showing few microseconds before disappearing , popup shows. have tried using mainlayout.setvisibility(view.invisible) not make difference. there way can change behavior main layout not show @ all. this main activity java file : public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); intent intent = new intent(this,animepopupactivity.class); startactivity(intent); finish(); } } this java file called main activity : public class animepopupactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); inputstream stream = null; try{ stream = getassets().open("382.gif"); } cat

php - How to have more than one "Theme Options" page with OptionTree? -

optiontree ( github ) allows create " theme options " page themes simply. how extend optiontree in order create " plugin options " page plugin? thank you! it's pretty simple. following code create page under settings page called test page . how optiontree creates own pages. /** * hook register admin pages */ add_action( 'init', 'register_options_pages' ); /** * registers required admin pages. */ function register_options_pages() { // execute in admin & if ot installed if ( is_admin() && function_exists( 'ot_register_settings' ) ) { // register pages ot_register_settings( array( array( 'id' => 'custom_options', 'pages' => array( array( 'id' => 'test_page', 'parent_slug' => 'options-general.php',

list - How can I create an indefinite iterations of objects in python? -

i'm new python , trying create program test methods of object creation. currently, i'm writing program involves creating objects, giving them unique numeric variable, , assigning them list future referencing. here's wrote create variable names: def getrectanglename(): rectname = list("rectangle") spawnedobjectlist.append(len(spawnedobjectlist)) rectname.append(str(len(spawnedobjectlist))) return rectname and that's passed onto turn string variable name. tried eval(), learned bad reason , didn't work anyway, , tried workarounds no avail. i figure there's plenty of games have indefinite number of characters on screen. there established way of making iterations of objects this? the objects have x , y act reference points display of rectangles on screen(the idea in future have each 1 move around on own, making lists of x , y draw rectangles isn't useful). edit: problem don't know how give each object own variable put

c - How do you declare multiple function pointers in a single line without typedeffing? -

more of matter of curiosity anything. want know if it's possible declare multiple function pointers in line, like: int = 1, b = 2; with function pointers? without having resort typedef . i've tried void (*foo = null, *bar = null)(int) . unsurprisingly, didn't work. try follows: void (*a)(int), (*b)(int); void test(int n) { printf("%d\n", n); } int main() { = null; = test; a(1); b = test; b(2); return 0; } edit: another form array of function pointers: void (*fun[2])(int) = {null, null}; void test(int n) { printf("%d\n",n); } int main() { fun[0] = null; fun[0] = test; fun[0](1); fun[1] = test; fun[1](2); }

php - Saving data for those with cookies disabled -

i've got website login feature, , i'm storing person's username cookie. i've got few questions: if want have person's username saved, should done solely session or cookie? what should have cookies disabled? should not store , have them log in each time? thanks. a user's details should saved in session. session variables stored on server, , session id exposed user. use cookies preserve login state on long time. make sure securely. users cookies disabled can use sessions via get variable. session id passed server via url. see how cookies , sessions work? more information.

Perl AnyEvent throwing HTTP Error 595 -

i have been trying make asynchronous requests using perl anyevent http module following code. my $headers = { 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-language'=> 'en-us,en;q=0.5', 'connection' => 'keep-alive' }; $request = http_request ( => "$url", timeout => 5, # seconds # persistent => 1, # keepalive => 1, headers => $headers, proxy => $proxyref, sub { ($body, $hdr) = @_; } ); i keep getting following response request: { 'reason' => 'connection timed out', 'url' => 'url requested', 'status' => 595 }; i've been checking anyevent documentation reasons error, haven't been successful that. cant find other useful threads on issue except suggestions retry on timeout, yields same result. simple 'wget' works on same

javascript - Change a variable value inside a Jquery .filter() function -

i have table has id 'mytable'. there textbox in write down item name find whether exists in mytable cell or not. have written following code - var retval=0; var search = $("#searchitem").val().trim(); $("table#mytable tr td").filter(function() { if($(this).text() == search){retval=1;alert('same item found');} else{retval=0;} }); the problem that, when finds same item in table cell shows alertbox. value of variable retval never changes. shows 0 . how can solve it? please try return false this var retval=0; var search = $("#searchitem").val().trim(); $("table#mytable tr td").filter(function() { if($(this).text() == search){ retval=1; alert('same item found'); return false; }else{ retval=0; } });

php - assignment within an echo statement -

in php file, have echo statement, outputs html, within want assignment based on onclick event. echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php' onclick='". $_session['dakno'] = $r[$j]; ."' >".$r[$j]."</a></td>"; i have tried lot of combinations, still getting syntax error because of onclick section. echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php' onclick='"<?php $_session['dakno'] = $r[$j]; ?> "' >".$r[$j]."</a></td>"; edits: i output field in table hyperlink. on clicking link, value of clicked item passed php file using session variable. $sno = 1; while($r = mysqli_fetch_array($rs)){ echo "<tr>"; echo "<td style='paddin

java - how to use value of one switch case in another switch case: value is Scanner inputs? -

i have 2 nested switches , wanted use value of 1 switch case in switch case. in below example, wanted use double variable temp_usr , pass argument method (cels()) in switch case, how can this? switch( switch1){ case 1: { system.out.println(" have selected celsius"); scanner temp_ip= new scanner(system.in); system.out.println("please enter temperature in celsius"); double temp_usr= temp_ip.nextdouble(); } break; case 2: ............... case 3: ............... switch(switch2) { case 1: { system.out.println("convert celsius"); system.out.println(cels(arg)); /*this argument should take value of temp_usr*/ } break; case 2: ......... case 3: ......... the variable visible inside block defined. if want open visibility declare outside switch. try this: double temp_usr= 0.0; //declaring here switch make visible in following code switch( switch1){ case 1: { system.out.println(" have selected celsius"); scanner temp_ip= new sca

java - JUNG: Paint graph on existing JPanel -

i starting jung , draw graph in jpanel of newly created jframe, unable paint same graph in existing panel of program developing. the function use this: private void demograph() { // graph<v, e> v type of vertices , e type of edges // note showing use of sparsegraph rather sparsemultigraph graph<integer, string> g = new sparsegraph<>(); // add vertices. above defined these type integer. g.addvertex((integer) 1); g.addvertex((integer) 2); g.addvertex((integer) 3); // g.addvertex((integer)1); // note if add same object again nothing changes // add edges. above defined these of type string // note default undirected edges. g.addedge("edge-a", 1, 2); // note java 1.5 auto-boxes primitives g.addedge("edge-b", 2, 3); // layout<v, e>, visualizationcomponent<v,e> layout<integer, string> layout = new circlelayout(g);

php - wrong parameter count in mysql_query -

i have error on php code. insert new row , error: wrong parameter count in mysql_query <?php include('../sec/inc_mysql_connect.php'); include 'googledistance.class.php'; $sql = "select vvbnummer, adres, postcode tblscheidsrechters";// echo($sql); $result = mysql_query($sql); $sql_sh = "select id, sporthaladres, postcode tblsporthal"; //echo('<br>' . $sql_sh); $result_sh = mysql_query($sql_sh); while($record = mysql_fetch_array($result)) { while($record_sh = mysql_fetch_array($result_sh)) { $fromaddress = $record['adres'] . ',' . $record['postcode']; //echo($fromaddress . '<br>'); $toaddress = $record_sh['sporthaladres'] . ',' . $record_sh['postcode']; //echo($toaddress . '<br>'); $gd = new googledistance($fromaddress, $toaddress); $vvb = $record['vvbnummer']; $shid = $record_sh['id']; $afstand = $gd->getdistance

javascript - Adding FontAwesome icons to a D3 graph -

i trying set icon fontawesome instead of text in d3 nodes. original implmentation, text: g.append('svg:text') .attr('x', 0) .attr('y', 4) .attr('class', 'id') .text(function(d) { return d.label; }); and try icons: g.append('svg:i') .attr('x', 0) .attr('y', 4) .attr('class', 'id icon-fixed-width icon-user'); but not working, though markup right, , css rules hit: icons not visible. any idea why? here related jsbin edit i have found alternative insert images: http://bl.ocks.org/mbostock/950642 node.append("image") .attr("xlink:href", "https://github.com/favicon.ico") .attr("x", -8) .attr("y", -8) .attr("width", 16) .attr("height", 16); which want do, not work <i> elements used fontawesome. you need use proper unicode inside normal text element, , set font-f

How to parse The following JSON in Javascript? -

i making web app nokia s40 platform . calling web service using javascript returns following json { "status_code": 200, "status_txt": "ok", "data": { "expand": [ { "short_url": "http:\/\/bit.ly\/msapps", "long_url": "http:\/\/www.microsoft.com\/web\/gallery\/?wt.mc_id=soc-in-wag-msp-m389", "user_hash": "gbl9jv", "global_hash": "ehgpgh" } ] } } i want obtain "short_url" , "long_url " values i using eval var obj = eval ("(" + xmlhttp.responsetext + ")"); where xmlhttp.responsetext conatains json response. please tried , worked var s = '{ "status_code": 200, "status_txt": "ok", "data": { "expand": [ { "short_url": "http://bit.ly/msapps", "long_url": "http://www.microsoft.com/web/gallery/?wt.mc_id=soc-in-wag

jquery - how show and hide div with time and click option to hide included? -

i have div display: none; want show hide in 5 seconds if in mean time user click on div should disappear once clicked. , seem can't both time disappear , click option. here code. $('#div').fadein(); $('#div').delay(5000).fadeout(); $('#div').click(function(){ $(this).fadeout(); }); if took out $('#div').delay(5000).fadeout(); won't disappear until click. if took out $('#div').click(function(){ $(this).fadeout(); }); won't disappear when user click on it. additional info the thing if add $('#div').delay(5000).fadeout(); before or after click code. div wait 5 sec , div unclickable. this should you're looking for. $('#div').fadein(); timerid = settimeout(function(){ $('#div').fadeout(); }, 5000); $('#div').click(function(){ $(this).fadeout(); cleartimeout(timerid); });

jquery - User-rotatable elements in the browser -

i'm creating requires end user move objects around using mouse, change size , rotate object. of can achieved using jqueryui (here) except rotating. need user able rotate objects. one option put slider adjusts css transform properties, if there's way in more intuitive way (a la powerpoint/photoshop) great. is there way this? http://jsfiddle.net/avpf6/1/ solution using drag able handle. // original element var ele = $('#selector'); $('#selector').draggable({}); // create handle dynamically $('<div></div>').appendto(ele).attr('id','handle').css({ 'position': 'absolute', 'bottom': 5, 'right': 5, 'height': 10, 'width': 10, 'background-color': 'orange' }); ele.css('position', 'relative'); $('#handle').draggable({ handle: '#handle', opacity: 0.01, helper: 'clone', drag: function(event, ui){ var rotatec

Deleting specific line in file using batch script -

i found out batch script not working properly. wanted write function deletes specific line in file, code: :unmark type %markpath% | findstr /b /v %1 > %markpath_copy% goto:eof yes, works, writes new content (without specific lines) in new file. instead of it, want overwrite existing file. that: :unmark type %markpath% | findstr /b /v %1 > %markpath% goto:eof but it's not working, file empty after code execution. can me figure out problem , how solve it? this style should work: @echo off set "markpath=%userprofile%\desktop\input.txt" set "markpath_copy=%userprofile%\desktop\searchfile.txt" findstr /b /v "%~1" <"%markpath%" > "%markpath_copy%" move /y "%markpath_copy%" "%markpath%" >nul

JSONObject Java equivalent for Objective C -

i'm working on api objective c has equivalent java version. used json.org elements define json parsing in java. import org.json.jsonobject; public class testcoderequest{ private hashmap<string,jsonobject> query = new hashmap<string, jsonobject>(); private jsonobject queryresult; } and public testcoderequest add(string endpoint, object... fields) { jsonobject endpointquery; if ((endpointquery = query.get(endpoint)) == null) { endpointquery = new jsonobject(); query.put(endpoint,endpointquery); } jsonobject sq = endpointquery; (int i=0;i<fields.length-2;i++) { jsonobject tmp = sq; if(sq.has((string)fields[i])){ try { sq = sq.getjsonobject((string)fields[i]); } catch(exception e) { throw new semantics3exception( "invalid constraint", "cannot add cons

c# - How can we remove certain folder name from the path and return new path? -

i have path: "c:\\users\\dev\\test\\testresults\\config\\report.xml" i need check if path has folder "testresults", if has need remove , return new path as "c:\\users\\dev\\test\\config\\report.xml" i know can achieve using trim , split. make sure pick right choice. best way of achieving this? any appriciated. i not use string replace method in case. why? e.g. : string path = "c:\\users1\\users2\\users122\\users13\\users133\\filename.xml"; path = path.replace("\\testresults", string.empty); // "c:\users222333\filename.xml" that not expected. so how fix this, path = string.join(path.directoryseparatorchar.tostring(), path.split(path.directoryseparatorchar).where(x=> x!="users1").toarray())); //c:\users2\users122\users13\users133\filename.xml

mysql - Select latest updated categories based on their items -

i have mysql database , there's categories table this: id name parent -------------------------- 1 news 0 2 analysis 0 3 europe 1 4 middle east 1 5 asia 1 6 americas 1 7 commentaries 2 8 interviews 2 9 articles 2 10 reports 2 and items table this: id created catid title --------------------------------------------- 1 2013-08-12 20:15:00 3 foo 2 2013-08-12 19:15:00 3 bar 3 2013-08-12 18:15:00 4 foobar 4 2013-08-12 17:15:00 4 barfoor 5 2013-08-12 16:15:00 8 boofar 6 2013-08-12 15:15:00 9 farfar 7 2013-08-11 16:45:00 10 farfarbar 8 2013-08-11 16:15:00 5 foofoobar 10 2013-08-10 16:15:00 7 foobarbar what want list categories children of specified parent , have latest items in them. example if want latest updated categories of news (catid=1) section

javascript - Iframe obstructing the mousemove event from occuring -

i attached event on body. transparent iframe appears on body behind popup. want call mousemove event on body, popup disappears mousemove occurs on iframe. i've had issue before. happens when add iframe body events sent body mousemove being obstructed iframe. i've fixed adding absolute positioned div 100% height , width on iframe, whenever popup opens. div should have higher z-index iframe . instead of listening mousemove on body listen div . remove div whenever closing popup.

c++ - Returning std::move(f) in std::for_each -

i'm writing implementation of standard c++ library study. the c++11 standard says for_each returns std::move(f) . template <class inputiterator, class function> function for_each(inputiterator first, inputiterator last, function f); returns: std::move(f). i thought function scope local variable move-constructed when it's returned. should return move(f) explicitly? from josuttis 's the c++ standard library you don’t have , should not move() return values. according language rules, standard specifies following code x foo () { x x; ... return x; } the following behavior guaranteed: • if x has accessible copy or move constructor, compiler may choose elide copy. so-called (named) return value optimization ((n)rvo) , specified before c++11 , supported compilers. • otherwise, if x has move constructor, x moved. • otherwise, if x has copy constructor, x copied. • otherwise, compile-time error emitted. from §25.2.4 (for_each)

python - How to Plot realistic curves using Scipy -

Image
my python program able plot graphs it's curves unrealistic. for example : how can smooth-en graph using scipy? have seen previous tutorials regarding matter tended use numpy , arange() features. since program doesn't derive points plotted numpy think it's features useless in scenario. import tkinter tk import ttk import sympy import matplotlib.pyplot plt x = sympy.symbols('x') class interface(ttk.frame): def __init__(self,parent=none): ttk.frame.__init__(self,parent) self.parent = parent self.initui() def initui(self): self.x_from_1 = ttk.label(self.parent, text= ' x values should : ') self.x_from_2 = ttk.label(self.parent, text = ' : ') self.x_from_1_inp = ttk.entry(self.parent) self.x_from_2_inp = ttk.entry(self.parent) self.equation_label = ttk.label(self.parent,text = 'equation : ') self.equation = ttk.entry(self.parent) self.submit = tt