Posts

Showing posts from February, 2015

How to create an Overflow menu and combine it with an option menu ? "android" -

hi guys new in android development want ask how can create overflow menu 2 items , how can combine option menu did looks this public class mainactivity extends activity { @override public boolean oncreateoptionsmenu(android.view.menu menu) { super.oncreateoptionsmenu(menu); menuinflater blabla = getmenuinflater(); blabla.inflate(r.menu.options_menu ,menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { switch(item.getitemid()){ case r.id.oursponsors: intent = new intent("com.--.------.------"); startactivity(i); break; case r.id.exit: finish(); break; } return false; } xml <item android:title="our sponsors" android:id="@+id/oursponsors" android:icon="@drawable/image" /> <item android:title="exit" android:id="@+id/exit" android:icon="@dra

wordpress - Javascript Inline and External Script difference -

i need help, porting internal scripts on website single js file speed website according google , yahoo page speed recommendations. i have following script in page footer.php (i using wordpress) <script> (function ($) { jquery(function () { var $container = $('#container'); $container.imagesloaded(function () { $container.masonry({ itemselector: '.box', columnwidth: 100 }); }); $container.infinitescroll({ navselector: '.post-nav', nextselector: '.previous a', itemselector: '.box', loading: { finishedmsg: 'no more pages load.', img: '/wp-content/themes/images/ajax-loader.gif' } }, function (newelements) { var $newelems = $(newelements).css({ opacity: 0 }); $newelems.imagesloaded(function () { $newelems.animate({ opacity: 1

android - Why i can't connect to mysql database in java? -

i found code in tutorial isn't working when debug try connection , isn't throw exception go block without line of code under drivermanager.getconnection(). why? has idea? connection con = null; statement st = null; resultset rs = null; string url = "jdbc:mysql://host/databasename"; string user = "user"; string password = "pass"; try { class.forname("com.mysql.jdbc.driver"); } catch (classnotfoundexception e1) { // todo auto-generated catch block e1.printstacktrace(); } try { con = (connection) drivermanager.getconnection(url, user, password); st = (statement) con.createstatement(); rs = st.executequery("select * message"); if (rs.next()) { system.out.println(rs.getstring

css3 - Centering issue when using flexbox where the content is larger than the container -

i'm trying center element (both horizontally , vertically) following conditions: element's display inline-block, since want width/height calculated depending on content. when container larger element everything fine . however, problem starts when element larger container, , the element gets width of container , not content . thanks in advance, oren just in case jsfiddle down, here's code snippets: <div class="working_area"> <div class="image_container"> <img src="http://eofdreams.com/data_images/dreams/bear/bear-05.jpg"/> </div> </div> and .working_area { background: yellow; position: absolute; width: 600px; height: 600px; display: -webkit-flex; -webkit-justify-content: center; -webkit-align-items: center; } .image_container { display: inline-block; /*shrink bit*/ -webkit-transform: scale(0.7); /*-webkit-transform-origin: center center;*/ }

Does SDK 2.0 work outside of Rally? -

i'm trying migrate rally app sdk version 1.32 version 2.0p. i know in order run app outside of rally in 1.32, prepend direct server url. however, in 2.0p documentation, seems show examples of running apps within custom html app in rally. can apps in sdk v2.0p run outside of rally? thanks. the current version 2.0rc1. supports running apps outside of rally full url : <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0rc1/sdk.js"></script>

cocos2d-x android compile ERROR -

i can run code in vc2012. need compile code android use linux system run ./build_native.sh . terminal turn out this staticlibrary : libchipmunk.a compile thumb : cpufeatures <= cpu-features.c staticlibrary : libcpufeatures.a sharedlibrary : libgame.so /mydata/data/java/adt-bundle-linux-x86_64-20130717/android-ndk-r8e/toolchains/arm-linux- androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux- androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs/game_shared/__/__/classes/appdelegate.o: in function appdelegate::applicationdidfinishlaunching():jni/../../classes/appdelegate.cpp:29: error: undefined reference 'cpwscene::createscene()' collect2: ld returned 1 exit status make: *** [obj/local/armeabi/libgame.so] error 1 make: leaving directory `/mydata/workspace/c++/cocos2d-2.1rc0-x-2.1.3/workspace/classdesgin/proj.android' you have add cpwscene.cpp file android.mk file compiler can compile file. android.mk fil

Accessing a Javascript prototype function -

i have prototype function such event. prototype func("input_element_id").event("keyup",function(){ alert("works on keyup in input!"); } func.prototype= { keyup: function(func){ //adding event listener , callback using func }, event: function(e,func) { //what here call function "keyup" } }; the prototype name in variable e . how can call function using variable name? i doing this, passing "keyup keydown" add keyup , keydown listeners, better calling each prototype function individually. thanks. var func = function(element){ this.element = element; }; func.prototype = { keyup: function(handler){ this.element.onkeyup = handler; }, event: function(e,handler){ switch(e){ case 'keyup': return this.keyup(handler); break; } } } http://jsfiddle.net/ydekw/

controller - Matlab .txt file read error -

i'm using matlab pi (proportional integral) controller. i'm trying control "virtual robot" agent via .txt files. simulated agent writes errors in .txt file. run through matlab , set speed via second .txt file, agent reads, in realtime. the problem matlab tries read error file while agent using (at least that's think happening) , error message: ??? error using ==> rfinputs>localtimerespcheck @ 421 final time must positive number. error in ==> pi_reg @ 42 [v,t]=lsim(pid_d,e,t); is there way avoid , have synchronized perfect every time? here code i'm using ( e.txt error file, v.txt speed file): clc, clear all, close kp=1.3; ki=0.32; kd=0; ts=0.008; pid_c = tf([kd kp ki],[1 0]); pid_d = c2d(pid_c,ts); fid=fopen('e.txt'); r=textscan(fid,'%f','\r\r'); fclose(fid); e=r{1}; while length(e)<2464 s = di

javascript - read .env file and convert all lines into an object -

i'm trying read .env file foreman using read env variables might want have when starting node server. i'm using: var path = require("path"), _ = require("underscore"), fs = require("fs"), variables = fs.readfilesync(path.resolve(__dirname, ".env"), "utf8"); at point have string containing this: node_env=development port=8080 i convert string object can read this: { node_env: "development", port: 8080 } i'm not sure how it. thinking of regex have no clue how read line line. or how type of variable ? can detect if it's string or number ( thinking see if there numbers means it's number ? ) ? string.replace primary means simple parsing: var env = {} variables.replace(/(\w+)=(.+)/g, function($0, $1, $2) { env[$1] = $2 }) to convert numeric values 8080 numbers, variables.replace(/(\w+)=((\d+)|.+)/g, function($0, $1, $2, $3) { env[$1] = $3 ? number($3) :

javascript - datetime from stripe being formatted with angularjs -

so stripe giving me 1374030547 date string. when use {{ mydatevar | date: 'mediumdata'}} in angular it's returning jan 16, 1970 rails able take same date string , return 2013-07-16 accurate date. so doing wrong angular here? the date string needs in millis, if have value 1374030547000, should return today's date. fiddle demonstrating this. function ctrl($scope) { $scope.mytime = "1374030547000"; }

php - MySQL Query with one-to-many -

i new mysql , need query here sample data columns: modelid styleid sequence 19463 316811 0 19463 316812 1 19463 316813 2 19463 316814 3 19463 316920 4 19463 316921 5 19727 318010 0 19727 318011 2 19727 318012 1 19727 318013 3 19884 320053 0 19884 320054 1 19884 320055 2 19884 320056 3 19998 321302 0 19998 321303 1 19998 321304 2 19998 321305 3 19998 321306 4 19998 321307 5 19998 321308 6 19998 321309 7 i need 1 styleid every modelid, preferably sequence of 0 or 1, sequence not matter, can random. the best result this, cant use sequence = 0 clause though: modelid styleid sequence 19463 316811 0 19727 318010 0 19884 320053 0 thanks try this select modelid, max(styleid),min(sequence) mytable group modelid

java - encountering getting desired output -

public class dog { string name; public void bark() { system.out.println(name+ "says warf!" ); } public static void main(string[] args) { dog dog1 = new dog(); dog1.bark(); dog1.name="bart"; //creation of array dog[] dogs= new dog[3]; //object reference dogs[0]= new dog(); dogs[1]= new dog(); dogs[2]= dog1; //accessing object variables dogs[0].name= "fred"; dogs[1].name= "marge"; system.out.println("last dog's name is"); system.out.println(dogs[2].name); //looping through array int x=0; while(x < (dogs.length)); { dogs[x].bark(); x=x+1; } } } hello everybody.... new java , been rookie in java programming.... in abouve code....as per "head first java "textbook... output should be "null says warf! last dog's name bart fred says warf! marge says warf!" but in above code coded in eclipse i

mysql - Sending a PHP variable to another page via click on anchor tag -

this simplified version of files working with: on product-list.php have like: <ul> <li><a href="prouduct-detail.php">product1</a></li> <li><a href="prouduct-detail.php">product2</a></li> <li><a href="prouduct-detail.php">product3</a></li> </ul> on product-detail.php want use like: include_once("db_config.php"); $product_detail_query = 'select * prod_details product_name = ???'; when clicks on product in product-list.php want text between anchor tags sent product-detail.php , beplaced in sql query @ product_name = (where have ???) can access specific row , lay out details. what best way achieve this? product list.php <a href="product-detail.php?product_id=1">product</a> on product-detail.php $product_id = (int)$_get['product_id']; then, bi

c# - Cant access list in other class with for loop -

i have real brain teaser right here , can't figure out doing wrong since code looks absolutely normal. little background information: since i've started working in xna/monogame environment 2 days wanted start off easy. i'm building astroid defender game, , i'm working on collision check. before got collision, found got rather odd null reference while im using loop loop through enemies inside list. list in class. upon startup initizalize spawnmanager class creates 20 enemies when class has been made so: class spawnmanager { //draw contentmanager mycontentmanager; //enemies public list<enemy> enemy = new list<enemy>(); public void loadcontent(contentmanager thecontentmanager) { mycontentmanager = thecontentmanager; (int = 0; < 20; i++) { enemy newenemy = new enemy(new vector2((800 / (20 + 1) * + 16.5f), 20), 500, 50, 25, 10, 2500, 100, 1, 3, 2, false); newenemy.loadcontent(

c++ - No compilation error comparing integer with string? -

probably many, typed typo int = 0; cout << < " "; //note '<' however, msvc++ compiler threw warning warning c4552: '<' : operator has no effect; expected operator side-effect though expected compilation error. indeed standard complaint code? implicit type conversion or overloading happen make code valid? confused whether < operator comparing string " " integer a or result of cout << a a related post here . the << operator has higher precedence < , parsed as (cout << a) < " "; you not comparing string integer. instead, comparing return value of ostream::operator<< , std::cout itself, string literal. isn't legal (in sense has unspecified result, , not meaningful) either, clang warns: warning: result of comparison against string literal unspecified the reason why compiles until c++11, std::ostream can implicitly converted void * . also, string liter

asp.net - Can't get LESS to compile Imports -

i using visual studio 2012 web essentials 2012, latest version. following direction article http://www.cutterscrossing.com/index.cfm/2013/5/20/skinning-bootstrap-tabs . have @import directives in less files , when save file css file created. however, nothing in css file. i've checked path, paths appear valid. my file structure is... a new empty web site called bootstrapless project css folder bootstrap folder bootstrap less files core folder css folder css files generated less files in core folder core.less overrides.less variables.less img folder bootstrap folder bootstrap glyphicons-halflings png files js folder bootstrap folder bootstrap js files in custom variables.less file have... @iconspritepath: "../../img/bootstrap/glyphicons-halflings.png"; @iconwhitespritepath: "../../img/bootstrap/

javascript - Fullcalendar --- Add / change Optioions on the fly -

i have found in source code: // function adding/overriding defaults function setdefaults(d) { $.extend(true, defaults, d); } i added fc.setdefaults = setdefaults; to have access function. try change options , render whole calendar them, nothing happens. $.fullcalendar.setdefaults({ axisformat:"h:mm" }); $('#calendar').fullcalendar('render'); is there way / set options after calendar created?

ios - Copy text of a PDF file to an NSString -

i want copy text of embedded pdf file in project nsstring . tried zachron's pdfiphone doesn't seem working on armv7. need work on armv7. i've read quartz framework guide, still don't know how text of pdf using quartz. if know solution, quartz or not, please write down. if target pdf not written in cjk(chinese,japanese , korean), way simpler one. download pdfkitten. has sample pdf parser. integrate pdfcore part of pdfkitten project. please note pdfkitten pre arc code. have set -fno-objc-arc pdfkitten files. in pdf, printing text operators tj , tj. so have modify call functions tj , tj. if have handle cjk pdf file, way more complicated. because many cjk pdf file has cid encoding. cid means character identification glyph. pdfkitten not cover such handling. have add cid ucs2 conversion function.

bash - Reading realtime output from airodump-ng -

when execute command airodump-ng mon0 >> output.txt , output.txt empty. need able run airodump-ng mon0 , after 5 seconds stop command , have access output. thoughts should begin look? using bash. start command background process, sleep 5 seconds, kill background process. may need redirect different stream stdout capturing output in file. this thread mentions stderr (which fd 2). can't verify here, can check descriptor number strace . command should show this: $ strace airodump-ng mon0 2>&1 | grep ^write ... write( 2 , "... the number in write statement file descriptor airodump-ng writes to. the script might (assuming stderr needs redirected): #!/bin/bash { airodump-ng mon0 2>> output.txt; } & pid=$! sleep 5 kill -term $pid cat output.txt

change order of views in linear layout android -

as know order of views in linear layout related order of them in xml file. possible change order java code indexing? i try remove views removeview(view) , add them addview(childview, index) in order like.

ios - How do I add a constraint such that a view is as wide as the widest of two other views? -

for example, labels a, b , c. label should have width of whichever wider, b or c. visually, along lines of @"h:[viewa(==max(viewb,viewc))]" if want ensure viewa simultaneously @ least wide both viewb , viewc , use 2 separate vfl statements, @"h:[viewa(>=viewb)]" , @"h:[viewa(>=viewc)]" . if want ensure not wider maximum width of viewb and/or viewc , define optional constraint (i.e. lower priority uilayoutpriorityrequired ) width of viewa equal 1 of them, e.g.: nslayoutconstraint *constraint = [nslayoutconstraint constraintwithitem:viewa attribute:nslayoutattributewidth relatedby:nslayoutrelationequal toitem:viewb attribute:nslayoutattributewidth

asp.net - User controls with update panel on each one do not update correctly -

i have 2 user controls on aspx page. both of them has update panel , updatemode property set conditional: first 1 (votecontrol): <asp:updatepanel id="voteupdatepanel" runat="server" updatemode="conditional"> <contenttemplate> <div class="vote"> <div class="counter"> <asp:label id="lblvotecount" runat="server" /> </div> <div class="vote-up"> <asp:imagebutton id="btnvote" runat="server" imageurl="~/app_themes/defaulttheme/images/br_up.png" onclick="btnvote_click" /> </div> </div> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="btnvote" eventname="click" /> </triggers> </asp:updatepanel> and other 1 (commentcontrol) updatepanelanimationextender : <asp:updatepanel id=&quo

php - How to keep a session alive after logging in (Codeigniter) -

we building webshop based on codeigniter. products saved in shopping cart of codeigniters' cart class. when visitor logs in it's account, products in cart removed because new session started when user logged in. how can keep products in cart @ point? if($query->num_rows() == 1) { $user = $query->row_array(); $data = array( 'userid' => $user['id'], 'email' => $user['email'], 'validated' => true ); $this->session->set_userdata($data); return true; } you have create new table in base, shoppingcarts, , pass items chart class in table, , user id, when user log in query table id , id of row got products.but when user bye delete rows in base , unset cart class $data = array( 'id' => 'sku_123abc', 'qty' => 1,

Python - How to transform a list of tuple to a tuple -

this question has answer here: how transform tuple string of values without comma , parentheses 4 answers i retrieved data sql query and i have list of tuple like: [(34.2424,), (-64.2344,) (76.3534,), (45.2344,)] and have string (34.2424, -64.2344, 76.3534, 45.2344,) does function exist can that? notice ',' @ end of each tuple... have difficulty rid of it if you're using python 2.x, can use: >>> = [(34.2424, -64.2344, 76.3534, 45.2344)] >>> print ' '.join(map(str, a[0])) '34.2424 -64.2344 76.3534 45.2344' in python 3.x, or python 2.x from __future__ import print_function , can use: >>> print(*a[0]) 34.2424 -64.2344 76.3534 45.2344 you seem have updated format of input data, so: first element each tuple... >>> = [(34.2424,), (-64.2344,), (76.3534,), (45.2344,)] >>&g

ruby on rails - how to uninstall spree_fancy -

i trying out spree rails gem. followed tutorial , added spree_fancy gem. how uninstall spree_fancy , go old look? commented out spree_fancy in gemfile, errors on page. commenting out , running bundle install not remove customizations done spree_fancy. appreciated. thank you. follow installation guide backwards - undo each step end start.

Send email via PHP function not working -

i'm having problems php mail function in php application. below code reason not work. i've spent last hour trying figure out why won't send email. please point me in right direction? 100% sure has nothing post variables form or query. thank much! <?php include 'inc/db.php'; $sellerid = $_post['sellerid']; $subject = $_post['subject']; $message = $_post['message']; $query = "select * users id='$sellerid'"; $result = $mainframeconnection->query($query); if (!$result) { die("error!"); } while ($field = $result->fetch_array()) { $to = $field['email']; } $headers = 'from: test@test.com' . "\r\n" . 'reply-to: test@test.com' . "\r\n" . 'x-mailer: php/' . phpversion(); mail($to, $subject, $message, $headers); header('location: message-sent.php'); ?>

python - Search child element in ET -

i'm trying search xml file. need check if 'localteam' name matches query (e.g 'team a') if match found check 'awayteam' name matches second condition (e.g 'team b'), elemt of below 'localteam' within same element if 'awayteam' matches query id of parent (in 'match') , exit search. i can localteam element i'm not sure how search awayteam , go 'up' level id... i've tried using child.iter() , child.find('awayteam'), neither has worked.. thus far have.. for child in root.iter('localteam'): gs_name = child.get('name') if gs_name == 'team a': print child.tag, child.attrib step_child in child.iter(): print step_child.tag, step_child.attrib gs_name = child.get('name') xml <scores sport="sports"> <category name="name" id="1419" file_group="usa"> <match

objective c - Cocoa app crashes when trying to open a save dialog: Timeout occured while waiting for the window -

i wrote html5 app , i'm making wrapper in cocoa mac. i'm in process of writing method take url , let user save disk. here method far: - (void) downloadfile: (nsstring *) url { nssavepanel * savepanel = [nssavepanel savepanel]; [savepanel setallowedfiletypes: @[@"png"]]; [savepanel setnamefieldstringvalue:@"test"]; [savepanel beginwithcompletionhandler:^(nsinteger result){ //nsarray * files = [[opendlg urls] valueforkey: @"relativepath"]; //[resultlistener choosefilenames: files] ; }]; [savepanel runmodal]; } however when invoke method (long after window made) app crashes , error in console: 2013-07-21 18:23:05.067 reditr[31458:d11f] rvs:__54-[nsremotesavepanel _runorderingoperationwithcontext:]_block_invoke_0319 : timeout occured while waiting window you don't want use both -runmodal , -beginwithcompletionhandler: . use 1 or other (preferably latter).

c++ - Could an optimizing compiler remove all runtime costs from std::unique_ptr? -

reading std::unique_ptr @ http://en.cppreference.com/w/cpp/memory/unique_ptr , naive impression smart enough compiler replace correct uses of unique_ptr bare pointers , put in delete when unique_ptr s destroyed. case? if so, of mainstream optimizing compilers this? if not, possible write some/all of unique_ptr s compile-time safety benefits optimized have no runtime cost (in space or time)? note (properly) worried premature optimization: answer here won't stop me using std::unique_ptr , i'm curious if it's awesome tool or awesome one. edit 2013/07/21 20:07 est: ok, tested following program (please let me know if there's wrong this): #include <climits> #include <chrono> #include <memory> #include <iostream> static const size_t iterations = 100; int main (int argc, char ** argv) { std::chrono::steady_clock::rep smart[iterations]; std::chrono::steady_clock::rep dumb[iterations]; volatile int contents; (size_t = 0; &l

amazon emr - nutch running on EMR -

can please guide me right direction. i'm trying nutch working on amazon emr. far, can nutch running locally , getting launched using shell scripts come it. however, on amazon, need specify jar location , options. can jar compiling myself. however, don't know start far startup options concerned. additionally, main difference between 1.x , nutch 2.0. 1 recommended on emr on other? in case you're still looking answer: when build nutch, see job jar in deploy directory, upload s3 , reference you're custom jar while setting emr job flow. you can add steps , mention main class example: org.apache.nutch.crawl.crawl , arguments want. doesn't change way works in local mode. example: urls -dir mycrawl -threads 10 -depth 5 -topn 1000 . you can know main class use looking @ bin/nutch script if intend use other crawl.java.

android - Backstack and memory leakage -

i have developed small api dialog fragments based on google support library simple requirements: api add (or replace) modal dialog api dismiss dialog programmatically or user can dismiss dialog pressing button does api creates memory leakage adding fragments backstack? public class dialogfragmentutils { private static final string dialog_tag = "dialogtag"; public static void showdialogfragment(@nullable activity activity, @notnull fragment fragment) { if (activity instanceof fragmentactivity) { fragmentactivity fragmentactivity = (fragmentactivity) activity; fragmentmanager fm = fragmentactivity.getsupportfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); fragment prev = fm.findfragmentbytag(dialog_tag); if (prev != null && prev.isadded()) { ft.remove(prev); } ft.add(fragment, dialog_tag); ft.addtobackstack(null); ft.commit(); } } public static v

How to declare nested objects in JavaScript? -

i'm trying create object contains object, think of dictionary: var dictionaries = {}; dictionaries.english_to_french = { {english:"hello",french:"bonjour"}, {english:"i want",french:"je veux"}, {english:"bla",french:"le bla"} }; but gives error uncaught syntaxerror: unexpected token { doing wrong? thanks ! edit i'm sorry did not clarify want do. edited code above. you're trying give object property, , property single object: dictionaries.english_to_french = {english:"hello",french:"bonjour"} ; you don't need { } . declare whole thing @ once: var dictionaries = { english_to_french: { english: "hello", french: "bonjour" } }; i suggest better format dictionaries might be: var dictionaries = { english_to_french: { "hello": "bonjour", "chicken": "poulet", // ? "englishman

javascript - Show hidden div, why code works in FF/Chrome but NOT in IE9? -

consider following example: <html> <head> </head> <body> <style type="text/css"> .hide { display: none; } </style> <button style="width:200;height:20;background-color:#b4cfec;font: bold 10px verdana" onclick="document.getelementbyid('cust_class').classlist.remove('hide');" >customer dimension</button> <div class="hide" id="cust_class">"lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div> </body> </html> i using document.getelementbyid(

iphone - webkit border image not loading mobile safari -

i'm having pretty strange problems on mobile website. 1 of elements, have css property: -webkit-border-image: url(images/speech_box_right.png) 24 10 4 10 stretch stretch; this image never loads - using developer mode, file seems never retrieved. what's strange on mobile user agent works, , load on phone well. can load image directly phone if type in filepath. has experienced issues mobile safari rendering border images? thanks! border-image shorthand property following 5 properties: border-image: source slice width outset repeat; in code see stretch given multiple times. can removing that? i tested in desktop safari 5 it's working fine without issues. border-image supported in safari 6 , safari 5 supports alternative, -webkit-border-image property.

Facebook JavaScript API for google chrome extension -

i make chrome extension specific page posts automatically. simple popup controller , background thread handle fb api interactive i cannot load facebook js api extension page official example method. the script jssdk loaded , executed checked chrome developer tools. but window.fb not defined script loaded!!! i add script tag manually. it appeared both background thread , popup window. if inject iframe load page, success loaded window.fb , popup login/authenticate window. had cross domain problem! the div#fb-root exist. menifest.json has content_security_policy script-src 'self' https://connect.facebook.net ; object-src 'self' i don't have solution, might lead in right direction. the problem might document.location of extension document. javascript running in extension scope, protocol "chrome-extension://", while many js libraries expect either "http" or "https". from looking @ following line @ jssdk fi

How to split an Android XML into three equal layout rectangles? -

Image
how split android xml view 3 equal layout rectangles image below? you want use vertical linearlayout, this: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightsum="3" > <framelayout android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:background="#ff0000" > </framelayout> <framelayout android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:background="#00ff00" > </framelayout> <framelayout android:layout_width="

php - Where is Doc Root -

when run code on localhost $root = $_server['document_root']; echo "doc root : $root <br />"; it responds with: doc root : c:/wamp/public_html/ when run same code on remote server responds with: doc root : /home/setine5/public_html notice not have trailing "/" i'm trying find way reference same piece of php on both localhost , remote server cannot because of missing forward slash. how done normally? you can not in advance if $_server['document_root'] contains slash @ end or not. varies according environment. in cases, doesn't have trailing / , in windows, trailing slash cause issues. the solution here, dave suggested, append trailing slash if doesn't exist. $_server['document_root'] = sprintf('%s/', rtrim($_server['document_root'], '/')); an alternative solution: $_server['document_root'] .= (substr($_server['document_root'], -1) == '/')?&

audio - Discrete Wavelet Transform in MATLAB -

i working audio signal processing , need perform 3-band dwt. trying use dwt function in matlab this. however, after reading function realized allows input 2 filters, hi , low band, need input 3. there anyway can this? thank you! how describing not how wavelets work. think should read documentation/tutorials/background information more understand working with. oli correct - happens multilevel decomposition detail , approximation computed each level, , filters applied approximation (low band) calculate next level. e.g: sig1=audioread('myfilename'); [lev1_lo lev1_hi]=dwt(sig1(:,1),'haar'); [lev2_lo lev2_hi]=dwt(lev1_lo,'haar'); [lev3_lo lev3_hi]=dwt(lev2_lo,'haar'); %etc you keep lev1_hi , lev2_hi , lev3_hi , lev3_lo 3-level decomposition. case, keep lev1_hi , lev2_hi , lev2_lo2 .

magento - "This customer email already exists" text error message -

Image
where "this customer email exists" text error message(my account)? in account , on form try change email address. if trying save exists email address saw error msg above. i need change in , tried looking around everywhere not find it. find form action pointing form action="<?php echo $this->geturl('customer/account/editpost') but editpostaction seems handling passwords change. can please tell me it? file? yes can change error message locale file of magento setup just go throw path yourproject\app\locale\en_us open mage_customer.csv file , go 408 line change second column text want put new message i hope solve problem. edit see below image , change message in column b

To push unique elements read from file using regex into array-Perl -

here file: heaven heavenly heavenns abc heavenns heavennly according code, heavenns , heavennly should pushed @myarr , , should in array 1 time. how that? my $regx = "heavenn\+"; $tmp=$regx; $tmp=~ s/[\\]//g; $regx=$tmp; print("\nnow regex:", $regx); $file = "myfilename.txt"; @myarr; open $fh, "<", $file; while ( $line = <$fh> ) { if ($line =~ /$regx/){ print $line; push (@myarr,$line); } } print ("\nmylist:", @myarr); #printing 2 times heavenns , heavennly this perl, there's more 1 way (tmtowtdi). here's 1 of them: #!/usr/bin/env perl use strict; use warnings; $regex = "heavenn+"; $rx = qr/$regex/; print "regex: $regex\n"; $file = "myfilename.txt"; %list; @myarr; open $fh, "<", $file or die "failed open $file: $?"; while ( $line = <$fh> ) { if ($line =~ $rx) { print $line; $list{$line}

jquery - javascript insert into form submit -

i'm trying send data via javascript through form, it's not working. ideas why? <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <form method="get" action="test.php"> <input id="myvar" type="hidden" name="albumid" /> <button type="submit" id="btnsubmit">submit</button> </form> <script type="text/javascript"> $("#btnsubmit").click(function(){ var album = '11'; document.getelementbyid('myvar').value = album; }); </script> test.php <?php echo $_get["albumid"]; ?> there several issues: you're missing http: in src when loading jquery library since loading jquery use $('#myvar').val(album); . see more on val() that being said try <script src="http://ajax.googleapis.com

html - PHP collecting user input and displaying it -

so have basic program allows collect user input , output user or in other words display in browser lets delete object onclick method. simple todo list. my problem how collect information , display each previous information in rows on page instead of going away when browser refreshed. know ideal database i'm trying keep simple , knowledge of databases far inadequate. feel php or javascript can resolve issue not clicking me. maybe loop or while loop job not sure, use help. thanks. <?php if (isset($_post["user"])) { $user_info = $_post["user"]; } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>manage todos</title> </head> <body> <form action="" method="post"> <input type="text" name="user"></input> <input type="submit" value="post"> </

java - Why does the method hash(int h) of HashMap like this? -

this question has answer here: understanding strange java hash function 6 answers static int hash(int h) { // function ensures hashcodes differ // constant multiples @ each bit position have bounded // number of collisions (approximately 8 @ default load factor). h ^= (h >>> 20) ^ (h >>> 12); return h ^ (h >>> 7) ^ (h >>> 4); } could tell me why hash method designned this?what benefit? if see open jdk source , this method have comments... /** * applies supplemental hash function given hashcode, * defends against poor quality hash functions. critical * because hashmap uses power-of-two length hash tables, * otherwise encounter collisions hashcodes not differ * in lower bits. note: null keys map hash 0, index 0. */

How that a row exists with specific values in MySQL -

i've got table looking like: productid uid version i want know if row specific values exists, don't need data returned. how this? try this: select exists(select * tablename productid=210)

objective c - how to access the files of Nested folders in Skydrive API? -

Image
nsarray *arr = [[operation.result objectforkey:@"data"] valueforkey:@"name"]; nsarray *arrid = [[operation.result objectforkey:@"data"] valueforkey:@"id"]; nsarray *folder=[[operation.result objectforkey:@"data"]valueforkey:@"type"]; [dictdocument setobject:arrid forkey:@"id"]; [dictdocument setobject:arr forkey:@"name"]; [dictdocument setobject:folder forkey:@"type"]; arrid===>folder.id,file.id arr===>filename folder====>type of file eg.folder,audio,video can't able access files of nested folders?? try this,and once check in copy bundle identifiers files added succeessfully or not. nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"vid" oftype:@"mp4"]; nsurl *fileurl = [nsurl fileurlwithpath:filepath]; avplayer = [[avaudioplayer alloc]initwithcontentsofurl:fileurl error:nil]; avplayer.delegate = self; [avplayer p

java - JSP Page Forward Output Includes content from previous form -

the problem is: have page1.jsp submitted , forwarded page2.jsp. problem forwarded output should content in page2.jsp, instead of showing me content page1.jsp , content page2.jsp i'm using requestdispatcher.forward(string) don know why happening ps: i'm using je 1.4 well seems have got method signature incorrect . per javaee 1.4 api : public void forward(servletrequest request,servletresponse response) throws servletexception, java.io.ioexception hence code should : requestdispatcher dispatcher = request.getrequestdispatcher("page2.jsp); dispatcher.forward( request, response ); better , can use <jsp:forward> standard action. the jsp contains action stops processing, clears buffer, , forwards request target resource. note calling jsp should not write response prior action. suggested reading: how avoid java code in jsp-files?

php - How do I connect to the database server? -

i need connect php code sql server, using wamp server php v5.3.0, apache 2.2.11. i have downloaded sqlsrv30.exe , copy files ext folder of php, , apache bin directory, in php.ini have added following extensions: extension=php_sqlsrv_53_ts.dll extension=php_pdo_sqlsrv_53_ts.dll without ; , still getting following message: fatal error:fatal error: call undefined function sqlsrv_connect() in c:\wamp\www\tpphp\sqlserver\tp.php on line 7. i think libraries not loading. what should connect sql server using php? is wamp 64 bit?change 32 bit version,because sql driver microsoft not compatible. , can use phpinfo(); see if libraries loaded. can`t comment,so wrote answer.

gdi+ - How to create a gif image with C# -

i want create gif file several frames. want use method microsoft support-- image.saveadd but don't know how set encoderparameters paramater make gif file. i can't find documents refer. how create gif file image.saveadd probably, late useful original poster, managed create proper gif using system.drawing. code below based on jschroedl's answer, sets frame delays , number of animation loops. // gdi+ constants absent system.drawing. const int propertytagframedelay = 0x5100; const int propertytagloopcount = 0x5101; const short propertytagtypelong = 4; const short propertytagtypeshort = 3; const inr uintbytes = 4; //... var gifencoder = getencoder(imageformat.gif); // params of first frame. var encoderparams1 = new encoderparameters(1); encoderparams1.param[0] = new encoderparameter(encoder.saveflag, (long)encodervalue.multiframe); // params of other frames. var encoderparamsn = new encoderparameters(1); encoderparamsn.param[0] = new encoderparameter(encod

c++ - What type should I use for a range (of array indices)? -

i need write functions returning ranges within array (you may, if like, assume they're specified starting position , length). can't return tuple, need return other type (and maybe it's idea anyway). now, i'd return that's both (somewhat) standard , not incur performance penalty due vtables, convoluted ctors etc. the options come mind are: std::pair<unsigned> (or std::pair<size_t> ). a struct wrapping 2 unsigned s (or size_t 's). rolling own range class, sugar-coating utility methods. i tried looking proper range class, couldn't find one. it's kind of strange nothing in standard library/stl uses class ranges. are there better alternatives? , if there aren't, of above recommend? the main reason why hard answer it's not clear kinds of situations range used. don't know yet exactly. in situations recommend creating own class, because keeps flexible. can add member functions , nested typedefs needed. if in

excel - To split multiple sheets present in a single xls into individual CSVs using PERL or UNIX -

i have single excel containing many sheets sheet1, sheet2, sheet3, etc. i need split excel individual csvs, i.e. sheet1--->file1.csv sheet2-->file2.csv sheet3-->file3.csv and on... i need either using perl or unix . want know record count each of individually generated csvs. please give suggestions asap. in advance.

mysql - Query with LEFT JOIN in a specific order -

i have table called products with: productid name and table called product_images with: imageid productid filename image_type image_order the image_type can 1 of 2 options (a or b) , order allows multiple images of each type shown in specific order. the query using like: select productid, name, ifnull((select filename product_images productid = products.productid order image_type desc, image_order limit 1), 'no_image.jpg') image_name products productid in (966, 967, 968) note: list of prodictid's specified search results. this working fine until added field product_images table alt/title text. so, tried following select productid, name, pi1.filename, pi1.alttag products left join (select * product_images product_images.productid = products.productid

canvas - Android drawBitmap paint -

i trying show bullets when user touched screen i making bullet here public projectile(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); paint = new paint(); bulletbitmap = bitmapfactory.decoderesource(context.getresources(), r.drawable.bullet); } public interface projectilelistener { public void onprojectilechanged(float delta, float angle); } public void setprojectilelistener(projectilelistener l) { listener = l; } public void setprojectiledirection(int x, int y, int size){ pos = new rect(x, y, size, size); invalidate(); } protected void ondraw(canvas c) { c.drawbitmap(bulletbitmap, pos, pos, paint); super.ondraw(c); } and call here projectile p = new projectile(toweranimation.this); p.setprojectiledirection(x, y, 50); projectile

jboss7.x - Override endpoint URL using @WebServiceRef on EJB via XML in JBoss AS7.x -

in jboss 5, following: @stateless public class myservicebean implements myservice { @webserviceref(name = "services/mywebservice") mywebport mywebservice; ... } and override mywebservice endpoint url in jboss.xml: <session> <ejb-name>myservicebean</ejb-name> <service-ref> <service-ref-name>services/mywebservice</service-ref-name> <service-impl-class>eg.mywebservice</service-impl-class> <port-component-ref> <service-endpoint-interface>eg.mywebport</service-endpoint-interface> <stub-property> <prop-name>javax.xml.ws.service.endpoint.address</prop-name> <prop-value>http://some.url.here</prop-value> </stub-property> </port-component-ref> </service-ref> </session> but in jboss 7, jboss.xml not used anymore , can't find how

css - Hiding default select arrow in Firefox 22 -

Image
following answer https://stackoverflow.com/a/17713753/407943 i've tried implementing same solution not work on windows 7 firefox 22, get: select { -moz-appearance: window; -webkit-appearance: none; background: #f5f5f5 url("/images/arrow_down.png") right center no-repeat; padding-right: 20px; } @-moz-document url-prefix() { .wrapper { background: #f5f5f5 url("/images/arrow_down.png") right center no-repeat; padding-right: 20px; } } edit: here's jsfiddle http://jsfiddle.net/tgbez/1/ update: trick stopped working of ff 30. no other fix far. keep eyes on full gist updates. how remove <select> arrow on firefox : -moz-appearance:none; doesn't work itself. need add text-indent , text-overflow . this: select { -moz-appearance: none; text-indent: 0.01px; text-overflow: ''; } live example: http://jsfiddle.net/joaocunha/ruebp/1/ learn details on gist: https://gist.github.com

c# - How to read ASCII control characters from INI -

i'm calling following native api read/write ini files [dllimport("kernel32.dll")] private static extern int getprivateprofilestring( // ini read string section, string key, string def, stringbuilder retval, int size, string filepath); [dllimport("kernel32.dll")] private static extern long writeprivateprofilestring( // ini write string section, string key, string val, string filepath); public string readini(string sectionstring, string keystring, string filepathstring) { stringbuilder temp = new stringbuilder(200000); int = getprivateprofilestring(sectionstring, keystring, "", temp, temp.capacity, filepathstring); return temp.tostring(); } // write (section, key, data, file path) public void writeini( string sectionstring, string keystring, string datastring, string filepathstring) { writeprivateprofilestring(sectionstring, keystring, da

android - How to add onclicklistener to dynamically generated text views -

i have dynamically created textviews in application. want give on click event textviews.. when click on textview, need id of textview.. you try following code. textview text = new textview(this); text.settext("text here"); ll.addview(text); text.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub toast.maketext(getapplicationcontext(), "id : "+arg0.getid(), toast.length_short).show(); } }); in "ll" layout add textview , after adding put clicklistener() click event. hope useful you.

database design - MySQL Union in View -

i'm having 2 large tables, product , product_variants. i'm using mysql view, cause need sql statement many times. database structure cannot changed atm. product: id | ismaster | ean | name | price ... product_variants: id | pid (fk on product.id) | ismaster | ean | name | price ... the view my_view contains select this: (select * `product`) union (select * `product_variants`) when i'm doing query this: select * my_view ean = '11110' it takes 0,5 1 second. if use content of view directly adding where each subquery, super fast (~0,004 sec): (select * `product` ean = '11110') union (select * `product_variants` ean = '11110') how can use faster method in view? needed change mysql function? tia matt you should use mysql command analyse query use explain select statement , check table , index structure. use command set profiling=1; then use select query use command show profiles query1; check result thing talk

javascript jquery add stylesheet if class is present -

can tell me why following doesn't work in 'head' <script type="text/javascript"> if ($('.company-color').length){ document.write("<link rel='stylesheet' href='company-color.css' type='text/css'>"); } </script> i have class present on pages , want insert above stylesheet page if class '.company-color' present. use jquery(function($){ if ($('.company-color').length){ $('body').append("<link rel='stylesheet' href='company-color.css' type='text/css'>"); // or head } })