Posts

Showing posts from March, 2015

javascript - How to read configuration set in option page from content_scripts of Chrome extension? -

using localstorage, try store users configs, , works well. // in options_page localstorage.setitem('mykey',someval); but it's difficult read configs content_scripts (´・ω・`) localstorage.getitem('mykey'); // because different 'window' scope i'm making using runtime.sendmessage // in content_scripts chrome.runtime.sendmessage(null, {purpose:'getconfig',configkey:'mykey'}, function(confhere){ // action } ); i think it's complex!! (and using 'chrome.storage' requires permission, ugly) there way read configs content_scripts of chrome extension? content scripts run within context of pages sharing dom , not extension. so, content script trying read localstorage read localstorage of page, , not extension. the way proposed correct , far know best way access setting info in content script. so, when content script created send message background settings (as have done) , in background add list...

c# - How to convert an arbitrary object to enum? -

i have object. either long or string , simplify code let's assume that. i have create method tries convert object provided enum. so: public object toenum(type enumtype, object value) { if(enumtype.isenum) { if(enum.isdefined(enumtype, value)) { var val = enum.parse(enumtype, (string)value); return val; } } return null; } with strings works well. numbers causes problems, because default underlying type enum int , not long , isdefined throws argumentexception . of course can many checks, conversions or try-catches. what want have clean , small code that. ideas how make readable , simple? it feels me want handle 3 cases: input right type strings integers in various types i believe want valid input: public object toenum(type enumtype, object value) { if (value == null) { throw new argumentnullexception("value"); } if (enumtype == null) { throw...

titanium - Keep the code together or split up? -

i building app in titanium studios, it's childrens sound app. going have 1 sound/animal per window. better split code(one(1) window per js-file) on different js files or should keep code in same app.js? also; first question on here bear me. all dependa how want design app, how code reused between windows , how complex it. in general it's split code between files wait until will.be big enouhh refactoring.

regex - Ensuring a matched string contains at least one uppercase character -

given string "this uppercase test url ( http://www.somedomain.com/some/path ). lowercase test url ( http://www.somedomain.com/some/path )" i have regex find urls: \(http://www.somedomain.com/(.*?)\) can amend return url if contains uppercase character in path? you can put positive lookahead check uppercase character: (?=\s*[a-z])\(http://www.somedomain.com/(.*?)\) ^^^^^^^^^^^^ it'll make sure there's @ least 1 uppercase character in string. regex101 demo if want make sure 'check' remains within brackets, can use this: \((?=[^)\s]*[a-z])http://www.somedomain.com/(.*?)\) regex101 demo

php - Wordpress menu: Remove list-items and apply ".current-menu-item" to anchor tag -

title says all. in short, how make wp_nav_menu(); output this: <nav> <a>menu item</a> <a class="current-menu-item">menu item</a> <a>menu item</a> <a>menu item</a> <a>menu item</a> </nav> i read http://css-tricks.com/snippets/wordpress/remove-li-elements-from-output-of-wp_nav_menu/ removes unordered list , list-items. but removing <li> s removes useful .current-menu-item class when you're on particular page. how class show on anchor tag instead? you can edit output via first parameter of function wp_nav_menu($args); . $args = array( 'theme_location' => '', 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' ...

c# - Can I create or generate an invalid System.Guid in .Net? -

can somehow invalid system.guid object created in .net (visual basic or c#). know guid.empty method not searching for. example invalid symbols or spaces or being short or longer valid 1 etc. thanks! can guid created invalid symbols or spaces or being short or longer valid 1 etc? no - guid 128-bit number can represented in 4 groups of hexadecimal numbers. there's no way string representation of guid contain other 32 hex characters (and 3 dashes). you can create string not represent valid guid , there's no way put guid object.

java - Formatting miliseconds to hh:mm:ss format -

i having miliseconds value , want display time subtracting 5 minutes current miliseconds value in hh:mm:ss format. code string str = string.format("%02d:%02d:%02d", timeunit.milliseconds.tohours((cal.gettimeinmillis()-300000)), timeunit.milliseconds.tominutes(cal.gettimeinmillis()-300000) - timeunit.hours.tominutes(timeunit.milliseconds.tohours(cal.gettimeinmillis()-300000)), timeunit.milliseconds.toseconds(cal.gettimeinmillis()-300000) - timeunit.minutes.toseconds(timeunit.milliseconds.tominutes(cal.gettimeinmillis()-300000))); toast.maketext(getapplicationcontext(), "alarm set."+str, toast.length_long).show() output now alarm set. 386467:25:00 output required alarm set. 07:25:00 as see minutes , seconds getting retrieved quiet right there's problem hours . p.s 1.i referred ...

excel - QueryTables.Add application error -

sorry if quite basic q - vb not spend majority of time... here's code i'm stuck on - (excel 2007) set qt = activesheet.querytables.add(connection:=str1, destination:=range("schedule!a4"), sql:=sqlstring) qt.name = "tequery" qt.refresh <-- error thrown on line when call refresh, 1004: application-defined or object-defined error, seems generic of error me figure out might issue. in locals window can see qt , activesheet.querytables objects behaving expect (non-null etc.), , i've checked query text returns sensible result when run @ data source. ideas? eta - i've noticed oracle provider ole db missing data connections wizard - new oracle client 11.2.0 install - got new machine since last used macro...could problem? glad answering own question once :) i had 64-bit client installed, excel 2007 couldn't connect, it's 32-bit application , required 32-bit client drivers. still - shame generic error message! ...

How to style ActionBar.NAVIGATION_MODE_LIST Android -

i trying apply changes spinner. spinneradapter = new myspinneradapter(getactivity().getapplicationcontext(), android.r.layout.simple_spinner_dropdown_item, list); i have been playing around themes , looks need apply in order make changes, not working. using right parent spinneritem style? missing? <style name="mytheme" parent="@style/theme.appcompat.light"> <item name="android:spinnerstyle">@style/spinner</item> </style> <style name="spinner" parent="@android:style/widget.spinner"> <item name="android:background">@color/pending_red</item> </style> i inflate 2 different layouts in adapter, 1 in public view getdropdownview , in public view getview doesnt android.r.layout.simple_spinner_dropdown_item has effect all. found solution i had use <item name="android:actiondropdownstyle">@style/spinner</item> instead of ...

Ruby class override without inheritance -

i've made experiment: class < hash def foo 'foo' end end class < hash def bar 'bar' end end so far result expected, second declaration extends first one. surprised of this: class def call puts foo puts bar end end the code above works, if declare later. otherwise get: typeerror: superclass mismatch class can assume in ruby, safe skipping superclass specification without side effects after making sure "original-first" declaration parsed? you able declare inheritance on first occurince of class definition, below variants work: when you've defined same class inheritance: class < hash end class < hash end when you've used default inheritance in second case, treated undefined inheritance: class < hash end class end when you've used default inheritance in both cases, default inheritance of object class: class end class end and below not: when you've used de...

sql - Incorrect syntax near 'PIVOT' -

Image
i'm running sql server 2008 r2. i'm trying build table takes data table structured this: company | ded_id | descr 10 1 medins 10 2 life 10 3 pensn ... 10 50 domrel and need build temp table out format this: company | desc1 | desc2 | desc3 ... | desc50 10 medins life pensn domrel so built following query: select * ( select company,'desc'+cast(ded_id varchar(2)) dedid,descr deduction ) deds pivot (max(descr)for dedid in([desc1],[desc2],[desc3])) descs so running gives following error: msg 325, level 15, state 1, line 6 incorrect syntax near 'pivot'. may need set compatibility level of current database higher value enable feature. see set compatibility_level option of alter database. i double checked compatibility level on database , set 100 can't issue. can think of other setting might causing behavior? the possible reason ...

c++ - libx264 compiled with MinGW - missing __umoddi3, __udivdi3, _fseeko64 and __chkstk_ms -

i'm willing use x264 in windows project, i've build library source using mingw , gcc static library. the library , header included correctly, problem linker complains, because __umoddi3, __udivdi3, _fseeko64 , __chkstk_ms. looks functions part of standard library, can find in windows? thanks. i wouldn't copy/past full answer here should read topic @ doom10.org in short, can't directly use mingw compiled .a libraries (static or shared) in msvs. need compile libx264.dll , make msvs specific .lib library .def file , use library linking.

c# - INotifyPropertyChanged with lambda based checkin on the receiving end -

there's plenty of code , example floating around on how use lambda expressions raise inotifypropertychanged events refactoring freiendly code. typically used as: notifyofpropertychanged(() => propertyname); my question is, how achieve similar on receiving end of things, you'd typcially have switch statement of sorts: private void someobject_propertychanged(object sender, propertychangedeventargs args) { switch (args.propertyname) { case "xyz": break; //... } } now nice somehow avoid using strings here things not break when changing property name... as half-way solution use embedded class public constants such as: public class myclass { public static class notifications { public const string property1 = "property1" //... } //... } and on receiving end: private void someobject_propertychanged(object sender, propertychangedeventargs args) { switch (args.propertyna...

c++ - Alternative to reinterpret_cast with constexpr functions -

below, find constexpr string literal crc32 computation. i had reinterpret string literal character char unsigned char . because reinterpret_cast not available in constexpr function, workaround small utility function two's complement manually little disappointed it. does exist more elegant solution deal kind of manipulation ? #include <iostream> class crc32gen { uint32_t m_[256] {}; static constexpr unsigned char reinterpret_cast_schar_to_uchar( char v ) { return v>=0 ? v : ~(v-1); } public: // algorithm http://create.stephan-brumme.com/crc32/#sarwate constexpr crc32gen() { constexpr uint32_t polynomial = 0xedb88320; (unsigned int = 0; <= 0xff; i++) { uint32_t crc = i; (unsigned int j = 0; j < 8; j++) crc = (crc >> 1) ^ (-int(crc & 1) & polynomial); m_[i] = crc; } } constexpr uint32_t operator()( const char* data ) const { ...

android - Set wallpaper from list<Bitmap> using FlipperView -

i have flipperview list , want set wallpaper use mywallpapermanager.setbitmap(bitmap), didn't understand how take exact picture load in flipperview last. working sample_0, didin't if try change .decoderesource using id. advance. public boolean onoptionsitemselected(menuitem item) { bitmap bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.sample_0); switch (item.getitemid()) { case r.id.action_set_wal: txtpages.settext("done"); try { wallpapermanager mywallpapermanager = wallpapermanager.getinstance(getapplicationcontext()); mywallpapermanager.setbitmap(bitmap); } catch (ioexception e) { } return true; } return false; }

statistics - calulating sample excess kurtosis using R package fBasics -

i used fbasics package calculate sample excess kurtosis of simple vector [1,2,3]: > library(fbasics) > x=c(1,2,3) > kurtosis(x) [1] -2.333333 attr(,"method") [1] "excess" what calculated based on wikipedia http://en.wikipedia.org/wiki/kurtosis#sample_kurtosis , -1.5. wonder why fbaswics package gives different result? thanks! use kurtosis moments package instead. > library(moments) > kurtosis(x) [1] 1.5 kurtosis momments computes estimator of pearson's measure of kurtosis. function implemented (if x numeric vector) follows: n <- length(x) n * sum((x - mean(x))^4)/(sum((x - mean(x))^2)^2) for excess of kurtosis use: > kurtosis(x)-3 [1] -1.5 now, understand what's different in kurtosis form fbasics, @ code, use: library(fbasics) methods("kurtosis") getanywhere("kurtosis.default") and if x numeric vector, excess of kurtosis defined in kurtosis fbasics (actually timedate, see commen...

Submit Form and return values using HTML / JQuery / PHP -

need ... homepage have 3 divs, #header, #content, #footer. other pages being opened inside #content div. in 1 of pages have form 2 select lists , 1 submit button. want click button , return page #content div, showing values select before. this: the origin is: 1 destiny is: 1 but code returns following ... notice: undefined variable: origin in ... notice: undefined variable: destiny in ... note: working if don't open page inside #content div my html: <form id="myform" name="myform" action="values.php" method="post"> <select id="origin" name="origin"> <option value="0" selected>-- select origin --</option> <option value="1">portugal</option></select> <select id="destiny" name="destiny"> <option value="0" selected>-- select destiny --</option> <option value=...

sql - PostgreSQL get last value in a comma separated list of values -

in postgresql table have column has values ax,b,c a,bd x,y j,k,l,m,n in short , have few comma separated strings in column each record. wanted last 1 in each record. ended this. select id, reverse(substr(reverse(mycolumn),1,position(',' in reverse(mycolumn)))) mytable order id ; is there easier way? with regexp_replace : select id, regexp_replace(mycolumn, '.*,', '') mytable order id;

python - Sci-kit learn: applying custom error function to favor False Positives? -

while scikit learn documentation fantastic, couldn't find if there way specify custom error function optimize in classification problem. backing bit, i'm working on text classification problem false positives better false negatives. because labeling text important user, , false positives @ worst waste small amount of time user, whereas false negatives cause potentially important information never seen. therefore i'd scale false negative errors (or false positive errors down, whichever) during optimization. i understand each algorithm optimizes different error function, there isn't one-size-fits-all solution in terms of supplying custom error function. there way? example, scaling labels work algorithm treats labels real values, wouldn't work svm, example, because svm scales labels -1,+1 under hood anyway. some estimators take class_weight constructor argument. assuming classes ["neg", "pos"] , can give negative class arbitrarily ...

PHP Prepared Statement Problems -

slowly getting used php prepared statements, still error "warning: mysqli_stmt::bind_result(): number of bind variables doesn't match number of fields in prepared statement in c:\users\pc\documents\xampp\htdocs\login.php on line 20". <?php $mysqli = new mysqli('localhost', 'c3337015', 'c3337015', 'members'); if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } if(isset($_get['loginemail'])){ session_start(); $stmt = $mysqli->prepare("select email members email=? , password=? limit 1"); $email = $_get['loginemail']; $password = $_get['loginpassword']; $password = sha1($password); $stmt->bind_param('ss', $email, $password); $stmt->execute(); $stmt->bind_result($email, $password); $stmt->store_result(); if($stmt->num_rows == 1) //to check if row exists ...

java - create alias with the same name but not the same signature -

in order use h2 database in our junit tests instead of calling oracle, blocked on creating aliases on h2 emulate oracle compatibility : i first declared alias to_char date char conversion : works fine create alias to_char $$ java.lang.string tochar(java.util.date date, string format) throws exception{ ... }$$; then try declare alias to_char number char conversion : h2 doesn't accept : create alias to_char $$ java.lang.string tochar(java.lang.number value){ ... }$$; it rejected following error message : org.h2.jdbc.jdbcsqlexception: function alias "to_char" exists; sql statement: create alias to_char $$ java.lang.string tochar(java.lang.number value){ return java.lang.string .valueof(value); }$$ i tried declare 2 functions in 1 block, : create alias to_char $$ java.lang.string tochar(int value){ ... } java.lang.string tochar(java.util.date date, string format) throws exception{ ... } $$; in ca...

c# - Use of an unassigned local string variable -

this question has answer here: c#: use of unassigned local variable, using foreach , if 5 answers im trying set function read values xml file the function following.. public string xmlreadvalue(string filepath, string element, string subelement) { xmldocument xml = new xmldocument(); xml.load(filepath); xmlnodelist elements = xml.selectnodes("//" + element); string valuee; foreach (xmlnode elemente in elements) { valuee = elemente.selectsinglenode(subelement).innertext; } return valuee; } when return value valuee says use of unassigned local variable 'valuee' what doing wrong? if elements empty never affect value valuee . you should initialize : string valuee = "";

Oracle Java stored procedures returning data -

i'm trying write java stored procedure return result. i've found doc on oracle website, none of examples provided return data http://docs.oracle.com/cd/b19306_01/java.102/b14187/cheight.htm#chdjjdgh i have created package follow: create or replace package test_proc function hello_world return varchar2; procedure insert_test(chaine varchar2, nombre number); end test_proc; the package body follow create or replace package body test_proc function hello_world return varchar2 language java name 'testproc.helloworld() return java.lang.string'; procedure insert_test(chaine varchar2, nombre number) language java name 'testproc.inserttest(java.lang.string, int)'; end test_proc; and java code public class testproc { public static void inserttest(string chaine, int nombre) { system.out.println("insert test..."); string sql = "insert test values(?,?)"; try { connection conn = drivermanager.getconnection("j...

printing - CSS hide placeholder on print -

this question has answer here: removing input placeholder on printable version of html page 2 answers is there way hide input's placeholder text in print style sheet. have form can optionally printed , faxed/mailed. don't know why out want that, that's client wants. placeholder text in way on printed document. taken accepted answer here: removing input placeholder on printable version of html page you can use print media query change text color transparent. doesn't "remove" text, makes invisible, same result... @media print { ::-webkit-input-placeholder { /* webkit browsers */ color: transparent; } :-moz-placeholder { /* mozilla firefox 4 18 */ color: transparent; } ::-moz-placeholder { /* mozilla firefox 19+ */ color: transparent; } :-ms-input-placeholder { /* internet explorer 10+ */ col...

mysql - PHP PDO multiple select query consistently dropping last rowset -

i'm experiencing appears bug using pdo statement make multiple selects. i'm building sql query has many selects, , regardless of how many select statements makes, last rowset dropped. here's truncated example of whats happening $pdo = /* connection stuff here */ $sql = "select 1; select 2; select 3; select 4;"; $statement = $pdo->query($sql); { $rowset = $statement->fetchall(); if($rowset) { // stuff $rowset } } while($statement->nextrowset()); doing above, 1-3 retrieved rowsets, 4 not. cannot explain why case. making subsequent queries same pdo object results in error: pdo::query(): sqlstate[hy000]: general error: 2014 cannot execute queries while other unbuffered queries active. consider using pdostatement::fetchall(). alternatively, if code ever going run against mysql, may enable query buffering setting pdo::mysql_attr_use_buffered_query attribute. the above do ... while ... routine based ...

statistics - Random vector a with elements from the uniform distribution in R -

i'm new r , i'm looking through book called "discovering statistics using r". although book implies don't need statistical background, of content isn't covered/explained... i'm wondering how simulate random vector 200 elements uniform distribution on interval (-50, 50). maybe i'm unsure because of terminology used. example created vector 200 elements range inbetween -50 , 50... i'm checking if correct. or there function generates random values there in java? haven't found on google either regarding r providing random values. runif(200, -50, 50) will trick.

python - Environment $PATH different when using venv -

i'm using pycharm on mac (osx mavericks) run simple script shown below. print path variable. have virtualenv in project directory. added run configuration in pycharm , tried different pythons: # file mytest.py import os print "path: ", os.environ['path'] when run system default python (/usr/bin/python) prints correct value path (i.e. path have configured in .bash_profile file,) kind of long , contains many directories. but when choose venv's python, path reduced only: /usr/bin:/bin:/usr/sbin:/sbin:/users/myname/projects/myproj/venv/bin this doesn't happen if run script terminal window. in case shows correct path both system's python , venv python. doesn't happen if deactivate venv , run venv/bin/python mytest.py . anyone knows how make correct path value set when running pycharm , using venv? you should know environment variables inherited. when define environment variable in .bash_profile becomes available in terminal (bash...

ruby - Compass/SASS creates files I cannot change -

today working on website using compass/sass. no idea why, of sudden when try run sudo compass create now, creates necessary files , directories, lock on them can't change them. have tried following, of steps working, end effect remains same: deleting visible files , recreating them deleting visible , invisible files command line sudo rm -rf [file/directory name] , cleaning sass cache reinstalling compass , sass reinstalling compass , sass after purging ruby , ruby gems i'm running ubuntu 12.04.4 lts. hope guys can me. ivor

android - nested linearlayout is not working properly -

i want edittext , send button in 1 row image in other row ...but using code edit text,send button,and image displaying in 1 row..can please tell me should display image in other row <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:orientation="horizontal" tools:context=".mainactivity" > <edittext android:id="@+id/edit_message " android:layout_weight="1" android:layout_width="0dp...

rounding - Reduce the decimal points in Python -

i have array array([0.79836512, 0.79700273, 0.82697546, 0.82016349, 0.79087192], dtype=float32) and want keep first 2 decimal points without round. so, need array that, array([0.79, 0.79, 0.82, 0.82, 0.79], dtype=float32) . is possible python ? thanks the standard approach truncating 2 decimals truncate x * 100 , divide 100, works numpy arrays: >>> np.trunc(a * 100) / 100 array([ 0.79000002, 0.79000002, 0.81999999, 0.81999999, 0.79000002], dtype=float32) don't put off trailing non-zero digits in output, artifact of floating-point imprecision: >>> np.float32(.79) 0.79000002

php - android convert dip to pixels? -

my issue want re-size images inside post showing 2 images per row my app send width of screen php api php api must convert dip pixels , set image width 50% of screen dip this aim doing far display d = getwindowmanager().getdefaultdisplay(); int w = display.getwidth(); int h = display.getheight(); string response = get_html_postinfo("bla.php?postid=1&h="+h+"&w="+w); //response append webview in php side $screen_dip_w = $_get['w']; $screen_dip_h = $_get['h']; //i want dip converted pixel how ? $screen_px_w = ( ? x $screen_dip_w ); $set_image_w = $screen_px_w/2; any idea ? thank u display.getwidth() , display.getheight() return size of screen in pixels, no conversion required. also, recommend switching using display.getsize(point outsize) width , height methods deprecated. developer.android.com/reference/android/view/display.html

sql - Cant find column but it exist -

hi im working on delphi 10 , sybase. im having issue 2 days ago , i've tried lot of things. set adoconnection properties in build, searh db , ready. can insert,delete , update when im trying make select x y z output column y not found when : select * administradores it work,but 1 need dont. code one. adoquery1.close ; adoquery1.sql.clear; adoquery1.sql.text:='select usu_administrador,pass_administrador administradores usu_administrador='+edit1.text+''; adoquery1.open; i tried sql syntax error ,open fields editor , dont have fields. post happen me, solution didnt work me. please,could me? you should use parameters in queries adoquery1.sql.text:='select usu_administrador, pass_administrador ' + ' administradores usu_administrador = :paramadminname'; adoquery1.parambyname('paramadminname').value := edit1.text; also, reason why query didn't work value in edit1 must in quotes work in sql adoquer...

nosql - MongoDb C# driver - test authentication mode -

using c# mongodb driver, there way query server find out if started with: mongod --auth or mongod ? thanks. there ticket on mongodb tracker indicating getcmdlineopts command can used auth mode of server. db.runcommand("getcmdlineopts") returns { "argv" : [ "mongod", "--config", "mongodb.conf" ], "parsed" : { "auth" : "true", "config" : "mongodb.conf", ... }, "ok" : 1 } if --auth passed on command line appear in argv , parsed nodes; if set in mongodb.conf only appear in parsed node.

database - physical model data types -

i'm trying convert logical model physical model , saw example here http://www.1keydata.com/datawarehousing/data-modeling-levels.html doesn't have null or not null . next data types, null or not null need in physical model ?...also see lot varchar2(30) in models, know depends on situation of course when have varchar2(50) ? want when have column description, location or street address ?

java - Undefined function or method 'findjobj' for input arguments of type 'double'. MATLAB -

this question has answer here: “undefined function 'function_name' input arguments of type 'double'.” 1 answer i trying customize uitable in matlab using java. however, need java handle using findjobj keep getting error: ??? undefined function or method 'findjobj' input arguments of type 'double'. here code: mtable= handles.uitable1; jscroll=findjobj(mtable); jtable = mtable.gettable; i know passing number such as: handles.datatable = 3.0205 but that's same thing have seen in other posts....i tried passing get(handles.uitable1) gives me similar error saying struc array... please help! type which findjobj in command window. return "'findjobj' not found." function findjobj not built-in function. user-contributed function available on mathworks file exchange: findj...

constraints in a fitness function in MATLAB -

i need optimize weights in fitness function: f(x)=x(1)*a+x(2)*b+x(3)*c+x(4)*d; (where a,b,c,d numeral constants , x vector of 4 weights) and need define these simple constraints in function: each weight (x(i)) must between 0 , 1; and sum (x(i))=1; (i=1:4) could me please? assuming have optimization toolbox, x= linprog([a,b,c,d],[],[],[1 1 1 1],1,[0 0 0 0],[1,1,1,1]);

angularjs - How do I make angular.js reevaluate / recompile inner html? -

i'm making directive modifies it's inner html. code far: .directive('autotranslate', function($interpolate) { return function(scope, element, attr) { var html = element.html(); debugger; html = html.replace(/\[\[(\w+)\]\]/g, function(_, text) { return '<span translate="' + text + '"></span>'; }); element.html(html); } }) it works, except inner html not evaluated angular. want trigger revaluation of element 's subtree. there way that? thanks :) you have $compile inner html like .directive('autotranslate', function($interpolate, $compile) { return function(scope, element, attr) { var html = element.html(); debugger; html = html.replace(/\[\[(\w+)\]\]/g, function(_, text) { return '<span translate="' + text + '"></span>'; }); element.html(html); $compile(element.contents...

php - doctrine query WHERE u.status = 1 AND (u.type = 1 OR u.type = 2) -

i'm trying build search form. fill data this: private function _get_results() { $search_data = $this->input->post('type'); if ($search_data) { $search_data = implode(' or u.type = ', $search_data); $search_array[] = array( 'key' => 'u.type', 'value' => $search_data, 'operand' => 'eq'); if (count($search_array)) { $results = $this->accounts_model->get_search_results($search_array); } this model code. function get_search_results( $params = array(), $single_result = false, $order_by = array('order_by' => 'u.id', 'direction' => 'desc') ) { $qb = $this->doctrine->em->createquerybuilder(); $qb->select('u'); $qb->from($this->_entity, 'u'); $qb->where($qb->expr()->eq('u.status', 1)); foreach ($params $param) { ...

android - How use GridView in Notification -

hello! can use gridview in custom notifications? can read it? tutorial or manual? or... how make switch in notifications , dynamically scrolls? searched , not find anywhere information questions. sorry english. thank you!!! :) gridview 1 of supported widgets in remoteview gridlayout . you can use if create simple custom notification. take @ this tutorial . , take @ app.widgets documentation list of supported widgets. one more thing keep in mind content inside of notification not scrollable, keep in mind when add content grid

ios - Adding two UIBarButtomItems with image programmatically -

i trying use following code in viewdidload method add 2 uibarbuttonitems left side of navigation bar, second button shown: //nav bar buttons uiview* leftbuttonview = [[uiview alloc]initwithframe:cgrectmake(0, 0, 40, 40)]; uibutton* leftbutton = [uibutton buttonwithtype:uibuttontypesystem]; leftbutton.backgroundcolor = [uicolor clearcolor]; leftbutton.frame = leftbuttonview.frame; [leftbutton setimage:[uiimage imagenamed:@"totop"] forstate:uicontrolstatenormal]; [leftbutton settitle:@"" forstate:uicontrolstatenormal]; leftbutton.tintcolor = [uicolor redcolor]; //your desired color. leftbutton.autoresizessubviews = yes; leftbutton.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleleftmargin; [leftbutton addtarget:self action:@selector(totop:) forcontrolevents:uicontroleventtouchupinside]; uiview* leftbuttonview2 = [[uiview alloc]initwithframe:cgrectmake(85, 0, 40, 40)]; uibutton* leftbutton2 = [uibutton buttonwithtype:uibuttonty...

networking - How do I determine that the subnet was going to be .11.254 and .13.254? -

i figured out subnet mask both subnets 1 , 2. problem can't grasp how subnet turns 172.20.11.254 , 172.20.13.254 respectively? assume vslm, not certain. i'm learning this. got 172.20.8.0 , 172.20.6.0 subnet , know wrong now. can provide. to determine subnet mask work 172.20.0.0 network, first @ number of hosts required each subnet: subnet1 (connected fastethernet0/0) has 672 hosts. support 672 hosts, subnet mask of /22 required (10 host bits in 2n-2 formula afford 1022 host addresses in subnet). subnet2 (connected fastethernet0/1) has 258 hosts. support 258 hosts, subnet mask of /23 required (9 host bits in 2n-2 formula afford 510 host addresses in subnet). network address of 172.20.0.0 , masks needed fit requirements, need configure following ip address , subnet masks: for fastethernet0/0 connection: 172.20.8.0/22 third possible subnet. (172.20.0.0/22 first possible subnet , 172.20.4.0/22 second possible subnet.) 172.20.11.254 last possible ip address in subn...

Sessions with Google Cloud Endpoints [Python] -

i trying session service working cloud endpoints when user refresh page, not lose everything. i thought had figure out gae-session : https://github.com/dound/gae-sessions works locally. but reason when upload code, session not work. not sure why happening (ssl maybe?) i session class myapi(remote.service): def __init__(self): # retrieve session if exists self.session = get_current_session() @endpoints.method(message, message, path='app_init', http_method='post', name='app.init') def appinit(self, request): if not self.session.is_active(): logging.info('session active') else: logging.info('no active session) any idea on doing wrong or maybe better solution? thanks

mysql - GROUP BY with only first row of sequence of one column? -

at first here alpha version of want: http://sqlfiddle.com/#!2/45c89/2 however don't want count representative_id, rows lowest id, eg: (`id`, `economy_id`, `representative_id`) (1, 1, 5), <-this one, lowest id through same economy_id=1 (2, 1, 6), (3, 1, 7), (4, 1, 8), (5, 1, 3), (6, 1, 4), (7, 1, 1), (8, 1, 2), (9, 1, 102), (10, 2, 7), <-this one, lowest id through same economy_id=2 (11, 2, 8), (12, 2, 102), (13, 2, 1), (14, 2, 2), (15, 2, 3), (16, 2, 4), (17, 3, 3), <-this one, lowest id through same economy_id=3 (18, 3, 4), (19, 3, 1), (20, 3, 2), (21, 3, 102), (22, 4, 1), <-this one, lowest id through same economy_id=4 (23, 4, 2), (24, 4, 102), (25, 5, 1), <-this one, lowest id through same economy_id=5 (26, 5, 2), (27, 5, 102), (28, 5, 7), (29, 6, 1), <-this one, lowest id through same economy_id=6 the output should be: representative_id, count() according above example: 5, 1 7, 1 3, 1 1, 3 is possible in sql? if i'm understandi...

sql - join 78 specific codes from created table to linked table. Can't use IN() function (character limit), Can't do RI -

i have db (access 2010) pulling data from, trying make easier pull specific cases instead of mucking in excel. we have 78 product type codes classify account type. unfortunately can't use in() function because there many characters (there 1024 char limit). looked online , suggested make table inner join on product codes want. i created table codes want pull, joined on productcodetype in linked database table. unfortunately when run sql nothing shows up, blank. tried different join combinations no avail, read further , found can't enforce referential integrity on linked db tables non-linked db tables. i think problem i'm not sure, , don't know if i'm using right language, can't find similar issue mine i'm hoping it's easy fix , i'm not thinking right way. is there way select cases (78 product type codes) large database using in() or reference table when can't create new table in linked db? thank you, k you must use 2 tables ...

What to do with exceptions in java? -

i beginner in java programming. have code below socket socket = serversocketobj.accept(); bufferedwriter writer = new bufferedwriter(new outputstreamwriter(socket.getoutputstream())); try { writer.writeline(); } catch(ioexception e ) { //write logger here } { writer.close(); // throws ioexceptioin too. // possible memmory leak? socket.close(); } when try close writer should handle exception. don't know it. exception impossible in case? can ignore it? if don't know them, catch them , log them. simplest way of logging them e.printstacktrace() way, @ least you'll see there's problem if exception occurs. another approach re-throw exceptions upper-level code. e.g. if method (in sample code is) declares throw ioexception , there's nothing should worry about. let upper-level code worry it.

php - With Laravel 4 is there a way to stop it from creating a session when a user access a page? -

i have notice every time load page first time (new user) creates new session. want disable that. want creation of session when user logins in. so there way tell laravel 4 not create new session every time new person comes website? you try setting session driver blank string prevent laravel creating session config::set('session.driver','');

c# - How to rewrite SQL Union of two tables with Join in LINQ? -

i have 3 classes below: public class { public string id {get; set;} public string name {get; set;} public string age {get; set;} public bool isemployed {get; set;} public int roleid {get; set;} } public class b { public string id {get; set;} public string name {get; set;} public string age {get; set;} public int roleid {get; set;} } public class roles { public int id {get; set;} public string rolename {get; set;} ... } suppose these classes have own tables on dbms. i have sql query rewrite in linq (as elegantly possible) select a.name, a.age, roles.rolename, a.isemployed join roles on a.roleid = roles.id roles.rolename = 'admin' union select b.name, b.age, roles.rolename, '-' isemployed b join roles on b.roleid = roles.id roles.rolename = 'admin' currently have managed rewrite as: var filteredclassa = c in allclassas join role in allroles on role.id equals c.roleid role.rolename == ...

html - Responsive div layer with fixes height -

how can set div layer have e fixed height in pixels in same time height responsive in smaller resolution ? let's height of div is: html <div id="size"></div> css #size { height:500px; } if make height 100% resize , responsive. why need have fixed size , responsive in same time, because height using transition element happening div once clicked. find out if there sollution of problem. here fiddle example: http://jsfiddle.net/vladicorp/frnf5/ right style: #index_slider { width:100%; position: relative; overflow:hidden; float: left; transition:all 1s ease; height:430px; } have fixed size, , not responsive if 100% height responsive lusing transition effect. problem you can use height property in combination min-height : #size { height:100%; min-height:500px; } this make element stop resizing down when reaches 500px height. you can use height style in combination max-height style: #size { hei...

java - Spring Security for REST -

i enabled spring security rest application not getting authorized when using curl. security.xml <sec:http use-expressions="true" entry-point-ref="restauthenticationentrypoint"> <sec:intercept-url pattern="/rest/**" access="hasrole('role_user')" /> <sec:form-login authentication-success-handler-ref="mysuccesshandler" /> <sec:logout /> </sec:http> <beans:bean id="mysuccesshandler" class="net.himalay.security.mysavedrequestawareauthenticationsuccesshandler" /> <sec:authentication-manager alias="authenticationmanager"> <sec:authentication-provider> <sec:user-service> <sec:user name="temporary" password="temporary" authorities="role_admin" /> <sec:user name="user" password="userpass" authorities="role_user" /> ...

nsarray - NSPopupButton remove all the items except one -

) in nspopupbutton have store different items. these can change depending on other actions: nsarray* array = [nsarray arraywitharray:mynewobject]; // not know items found mynewobject //[_mypopupbutton removeallitems]; // ...but want mantain itematindex:0!! // ..and then: (nsdictionary *dict in array) { [_mypopupbutton additemwithtitle:[[dict objectforkey:miciomicio] lastpathcomponent]]; } my intention delete old items , add new ones. possible while maintaining item @ index 0? ...it nice! nsmenuitem *firstitem = [_mypopupbutton itematindex:0]; [_mypopupbutton removeallitems]; [[_mypopupbutton menu] additem:firstitem];

Drop down list in PHP page appearing blank -

i have drop down list gathers ocntents directory windows folders. once user chooses value , clicks on search, results pdf files contained in directory. turns out, cannot find reason why drop down list results blank. have included code screenshot of blank drop down list. curious enough, 1 record appears in drop down list shortcut link. please pardon ignorance, php newbie , code bit messy. running page on iis 7. <?php // cmm_tino.php error_reporting(e_all); /** * search pdf files based on directory name */ // activate show request // var_dump($_get); function getfilelist($dir) { // array hold return value $retval = array(); // add trailing slash if missing if(substr($dir, -1) != directory_separator) $dir .= directory_separator; // open pointer directory , read list of files $d = @dir($dir) or die("getfilelist: failed opening directory $dir reading"); while(false !== ($entry = $d->read())) { // skip hidden files if($entry[0] == ".") cont...

jquery - Using Javascript variables within a string -

this question has answer here: how add var text javascript 4 answers i using jquery output link webpage. part of link dynamic, , having trouble using variables , text together. variable gets treated text. doing wrong? my jquery: var new_collection_id= 1; var new_collection_title= 'this title'; .html('<a href="collection.php?id=1&collection=new_collection_id"> new_collection_title </a>') you need use concatenation . .html('<a href="collection.php?id=1&collection=' + new_collection_id + '">' + new_collection_title + ' </a>')

css - Line break in :after pseudo-element content lost when pasted into editor -

below well-known method add line break using :after pseudo-element: <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> .br:after { content: '\a'; white-space: pre; } </style> </head> <body> <span class="br">line 1</span> <span class="br">line 2</span> <span class="br">line 3</span> <span class="br">line 4</span> </body> </html> the problem when html content copied , pasted browser external editor, e.g. notepad or word, line breaks lost , text above looks as line 1 line 2 line 3 line 4 any workarounds? if want each span element appear on line of own, can set just .br { display: block; } if want have line break after span , while letting go same line preceding content, i’m afraid there...

c# - Assert windows closed in Coded UI Tests -

i'm developing set of coded ui tests wpf project. know how assert window closed? can't seem check properties of window after gone. should assert ui element null, maybe? the uitestcontrol class has method called waitforcontrolnotexist did trick!