Posts

sql - How to bound primary key to custom ON condition in Yii Relations? -

the problem: how bound primary key custom relation query? context, for: one source can relate several different modifications (many_many), each modification relate product (belongs_to). if several products has 1 source, means products same - that's criteria. (i can't merge same products, because may turn out not same, if merge them - can't split them back). so, when need find orders related product, want find orders same products, not current product. relation looks this: 'orderedproducts'=>array(self::has_many,'orderproduct','','on'=>('modification_id in ( select distinct ms2.modification_id products p1 left join products_modifications pm on pm.product_id = p1.product_id left join modifications_sources ms on ms.modification_id = pm.modification_id left join modifications_sources ms2 on ms2.source_id = ms.source_id p1.product_id='.$this->primarykey.' )')), 'orders'=>array(self::has_many,...

apache2 - Set PHP's open_basedir for all users' public_html via mod_userdir -

i have apache 2 web server allows access public_html directory each user via mod_userdir , this: <ifmodule mod_userdir.c> userdir public_html userdir disabled root <directory /home/*/public_html> # [*] configuration here </directory> </ifmodule> i additionally configure php's open_basedir directive forbid file access outside user's homedir. user jim , directive be php_admin_value open_basedir "/home/jim/" question: apache offer way through variable @ spot marked [*] above, following? <directory /home/*/public_html> php_admin_value open_basedir "${apache_current_directory}" </directory> i don't know mod_php, should work. assume apache_current_directory variable supposed point current directory context, placing "." take care of (unless mod php doesn't behave). let me know how goes. <directory /home/*/public_html> php_admin_value ...

android - Embedding Cordova WebView call native method -

i have added embedding cordova webview in native radio stream player app, , thats works perfekt. but want change native view (viewflipper) javascript calling native function, how can this? .. please help, have googled hours now! finaly got work!!! i had make cordova plugin, , call native function way... @override public boolean execute(string action, jsonarray args, final callbackcontext callbackcontext) throws jsonexception { if (action.equals("radio")) { cordova.getactivity().runonuithread(new runnable() { public void run() { // button click //cordova.getactivity().findviewbyid(r.id.playbutton).performclick(); // method call ((radioapp) cordova.getactivity()).setviewflipper(0); ((radioapp) cordova.getactivity()).startstream(); // todo: not in use yet! callbackcontext.success(); // thread-safe. } })...

Python 2.7: test if characters in a string are all Chinese characters -

the following code tests if characters in string chinese characters. works python 3 not python 2.7. how do in python 2.7? for ch in name: if ord(ch) < 0x4e00 or ord(ch) > 0x9fff: return false # byte str (you gae) in [1]: s = """chinese (汉语/漢語 hànyǔ or 中文 zhōngwén) group of related language varieties, several of not mutually intelligible,""" # unicode str in [2]: = u"""chinese (汉语/漢語 hànyǔ or 中文 zhōngwén) group of related language varieties, several of not mutually intelligible,""" # convert unicode using str.decode('utf-8') in [3]: print ''.join(c c in s.decode('utf-8') if u'\u4e00' <= c <= u'\u9fff') 汉语漢語中文 in [4]: print ''.join(c c in if u'\u4e00' <= c <= u'\u9fff') 汉语漢語中文 to make sure characters chinese, should do: all(u'\u4e00' <= c <= u'\u9fff'...

android - Broadcast receiver is not stopping -

i working on app automatically decline incoming calls specific numbers , send sms in return.my broadcast receiver should enabled app only. so, added ( android:enabled="false" ) this. but, receiver still on default. i'm struck here. <uses-permission android:name="android.permission.call_phone"/> <uses-permission android:name="android.permission.read_phone_state"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.sifydy.automsgr.automsgr" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> ...

c# - How is an Enumerable converted to a Dictionary? -

i have following code msdn sample : if (sheetdata.elements<row>().where(r => r.rowindex == rowindex).count() != 0) { row = sheetdata.elements<row>().where(r => r.rowindex == rowindex).first(); ... which refactored follows: dictionary<uint, row> rowdic = sheetdata.elements<row>().todictionary(r => r.rowindex.value); if (rowdic[rowindex].count() != 0) { row = rowdic[rowindex]; ... now, sensed if enumerable.todictionary<> method actually has enumerate through data, redundant, msdn documentation not how conversion takes place. the alternative i'm thinking of using is: var foundrow = sheetdata.elements<row>().where(r => r.rowindex == rowindex); if (foundrow.count() != 0) { row = foundrow.first(); ... however, know possibly previous experiences faster , why. thanks. the cleaner alternative is: var row = sheetdata.elements<row>() .firstordefault(r => r.rowindex == rowind...

Bash command as variable -

i trying store start of sed command inside variable this: sedcmd="sed -i '' " later execute command so: $sedcmd s/$orig_pkg/$package_name/g $f and doesn't work. running script bash -x, can see being expanded like: sed -i ''\'''\''' what correct way express this? define shell function: mysed () { sed -i "" "$@" } and call this: $ mysed s/$orig_pkg/$package_name/g $f