Posts

php - render data via PDO::FETCH_FUNC vs loop -

i've been using 2 methods render data. the first one: function name($id,$name){ return '<div id="'.$id.'">'.$name.'</div>'; } echo implode($pdo->query("select id,name user")->fetchall(pdo::fetch_func,'name')); the second one: $users = $pdo->query("select id,name user")->fetchall(pdo::fetch_obj); foreach($users $user){ echo name($user->id,$user->name); } i don't understand how pdo::fetch_func works. tried figure out. however, not well-documented. could please explain fetch mode? , also, 1 performs better? thank you. both methods wrong , have learn how use templates , how separate business logic presentation logic. $users = $pdo->query("select id,name user")->fetchall(pdo::fetch_obj); tpl::assign('users', $users); is code business logic part. then in template <?php foreach $users $row): ?> <div id="<?=$...

android - Launch Google Drive App from another app at certain path -

can tell me if possible open google drive app @ path? know google drive api allow list files every folder, prefer use google drive app if possible. thank you. try excelent answer with this, can open google drive native app app.

c# - How to check if file contains strings, which will double repeat sign? -

i check if file containing strings, separated # contains double repeat sign. example: have file this: 1234#224859#123567 i reading file , putting strings separated # array. find strings have digit repeated next each other (in case 224859 ) , return position of first digit repeats in string? this have far: arraylist list = new arraylist(); openfiledialog openfile1 = new openfiledialog(); int size = -1; dialogresult dr = openfile1.showdialog(); string file = openfile1.filename; try { string text = file.readalltext(file); size = text.length; string temp = ""; (int = 0; < text.length; i++) { if (text[i] != '#') { temp += text[i].tostring(); } else { list.add(temp); temp = ""; } ...

Rendering Static and Dynamic Graphics OpenGL -

i working on ios game using opengl pipeline. have been able render graphics want screen, however, calling gldrawelements many times , have concerns running performance issues eventually. have several static elements in game not need render on every render cycle. there way can render static elements 1 frame buffer , dynamic elements another? here's code have tried: static bool renderthisframebuffer = yes; if (renderthisframebuffer) { glbindframebuffer(gl_framebuffer, interframebuffer); glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glblendfunc(gl_src_alpha, gl_one_minus_src_alpha); glenable(gl_blend); glenable(gl_depth_test); // set projection matrix cc3glmatrix *projection = [cc3glmatrix matrix]; float h = 4.0f * openglview.frame.size.height / openglview.frame.size.width; [projection populatefromfrustumleft:-2 andright:2 andbottom:-h/2 andtop:h...

capistrano3 - capistrano - git ls-remote -h doesn't have the git url -

i'm new using capistrano. set correctly, when run cap staging deploy - debug [b678d5eb] command: ( git_askpass=/bin/echo git_ssh=/tmp/myproj/git-ssh.sh /usr/bin/env git ls-remote -h ) debug [b678d5eb] usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>... debug [b678d5eb] finished in 0.325 seconds exit status 129 (failed). i think git clone url should follow after -h, i'm not sure. i'm using capistrano 3.2.1. here's deploy.rb - lock '3.2.1' set :application, 'myproj' set :repository, 'https://vrao@git.test.com/scm/~vrao/myproj.git' set :scm_passphrase, 'blah' any great. never mind, following documentation capistrano 2x, while have 3.2.1 installed. for might face same issue, in capistrano 2x specify git repo setting repository variable, while in 3x it's been changed repo_url. changed , works fine. here's documentation recommend follow...

Limit bandwidth per-IP by value from HTTP Header -

i have file download site. limiting bandwidth per ip (!). limit should set dynamically http header backend. my current implementation uses x-accel-limit-rate (i can change header, it's not hard-coded anywhere) , limit current connection/request. is idea doable in g-wan? yes, can done. write g-wan handler extract x-accel-limit-rate http header. enforce policy using throttle_reply() g-wan api call documented here . an example available called throttle.c might further. the throttle_reply() g-wan function lets apply throttling on global basis or per connection , apply relevant throttling values either ip addresses or authenticated users , depending on needs. throttle_reply() can change download speed dynamically during lifespan of each connection can slow-down old connections , create new ones adaptive download rate. of course, can enforced on per client ip address (or cookie, or isp/datacenter record) deal huge workloads.

io - Do CPU usage numbers/percentages (e.g. Task Manager) include memory I/O times? -

this i've wondered never looked up. when os reports 100% cpu usage, mean bottleneck calculations performed cpu, or include stall times, loading data l1, l2, l3 , ram? if include stall times, there tool allows break figure down components? the cpu usage reported os includes time stalled waiting memory accesses (as stalls data dependencies on high latency computational operations division). i suspect 1 use performance counters better handle on taking time, not familiar details of using performance monitoring counters.

mysql - Need to SUM All Rows by a Non-Numeric Condition AND a GROUP BY -

i have table contains condition need test , total group total of number of groups equal value. example: group 1 total of conditions = 1 group 2 total of conditions = 14 group 3 total of conditions = 5 group 4 total of conditions = 1 etc. i need calculate total of each group total groups = 1 this base code have come basic group totals. (i'm using sum(if(condition = true,1,0)) in effort build query can used subquery): select sum(if(`condition` <> '' , `condition` not null,1,0)) totalerrors site_analytics group fourid; of course same as: select count(*) totalerrors site_analytics group fourid `condition` <> '' , `condition` not null; returns row each group group total. need group groups group total. either way need number of groups (fourid) = 1 (or 2,3,4 etc) the end result i'm looking generate report has number of groups = 1, 2,3,4,5,5+ i have tried using above queries sub-queries no success such as: select su...

Android KitKat Bluetooth ACL_CONNECTED and ACL_DISCONNECTED not working -

i have weird issue, broadcast receiver not receiving acl_connected , acl_disconnected on android 4.4.2. but have android phone 4.1.2 , works correctly. is known issue? here androidmanifest : <receiver android:name="com.example.myclass$bluetoothbroadcastreceiver" android:enabled="true" android:exported="false"> <intent-filter> <action android:name="android.bluetooth.device.action.acl_connected" /> <action android:name="android.bluetooth.device.action.acl_disconnected" /> <action android:name="android.bluetooth.adapter.action.state_changed"/> </intent-filter> </receiver> i have found issue. i removed android:enabled="true" , android:exported="false" , works on both 4.4.2 , 4.1.2

python - Django Registration with Custom User Model -

so using custom user model accounts.player , i'm using django-registration in project. with custom model encounters error. know write own registration code there way use custom model class django-registration. had on docs didn't find solution. i'm sure theres way using subclass i'm not sure how implement this. what files required , code need?? this did personal project of mine: class userprofile(models.model): user = models.onetoonefield(user, related_name = 'moreaboutuser', unique=true) age = .... gender = .... regarding error, don't know how since didn't provide traceback/code. can connect custom model user model onetoonefiel'

mysql - PHP Loop through an array second time (foreach) -

i have foreach loop through data provided pdo sql query: foreach ($team $row){ $count++; $teamnumber = 'team'.$count; if ($currentscores[0]['team'.$count] == ""){ $red = "red"; } echo "<strong><font color='".$red."'>".$row['name']."</font></strong>"; echo $currentscores[0]['team'.$count]; if ($count < 2) echo " vs "; } now, want loop again through $team array returns last value of array during second loop. i tried same thing: foreach ($team $row) { ..... ....... } how run again through array? simple enough, foreach loop on $row have previously. foreach($array $key => $val) { foreach($val $a => $b) { echo $b; } }

java - Enforce method overload -

looking @ great example polymorphism vs overriding vs overloading , consider scenario: abstract class human { public void gopee() { println("drop pants"); } } class male extends human { public void gopee() { super.gopee(); println("stand up"); } } class female extends human { public void gopee() { super.gopee(); println("sit down"); } } my questions: is possible, on concrete classes level, enforce using super.gopee() inside gopee() ? if - how ? is possible, on abstract class level, know concrete class had called super.gopee() ? rationale if need call method let's lifttoiletseat() somewhere on abstract class level. thank you. you can enforce not giving subclass choice, using simple template method pattern . in superclass wants enforce call super , don't give choice. make method final can't overridden, , call abstract protected method must overridden. superclass behavior enforce...

Append Xml Attributes in a SQL server Query -

i'm new in handling xml inside sql server , have question have not found example or answer, useful if guys me. i have various xml iside table "t1" under xml column type "xmlcol", xml structure: row 1 <icfd:ips totalir="0" totalit="7223.9"> <icfd:tras> <icfd:tra impt="aiv" ts="16" imp="517.1"/> <icfd:tra impt="sri" ts="8" imp="18.3"/> </icfd:tras> </icfd:ips> row 2 <icfd:ips totalir="10" totalit="123.9"> <icfd:tras> <icfd:tra impt="aiv" ts="34" imp="345.1"/> </icfd:tras> </icfd:ips> i'm trying obtain result this: tra totalir totalit ------------------------------------------- aiv(517.1),sri(18.3) 0 7223.9 aiv(345.1) 10 123.9 how correct way make query? i have i'm getting ...

batch file - .PIF With ? Allowed for a Variable Request -

up until have been using .pif shortcut "?" call variable used in batch file produce specific results. have on project 10,000 folders, , jobfind.pif tool satisfied quick search. moving or floating shortcut.lnk 1 folder in larger directory. program line call inside jobfind.pif s:\yourstruly\jobfind\jobfind.bat ? jobfind.bat contents %1 = ? explorer "p:\sdit_l~1\projects\000030%1" is there simple replacement olde fashion jobfind.pif tool? thank you, gpb you replace either command-line or gui vbscript. here's example: strjob = inputbox("enter job number:") createobject("wscript.shell") .run "explorer.exe p:\sdit_l~1\projects\000030" & strjob end

Apache redirect with a relative path -

i want clear doubt, it's possible in apache make "alias" (mask) port ?? let make use of example: in server have apache running in *:80 , application running *:8080, inside domain called www.example.com . so, i'm think if possible , how can make "alias" if use www.example.com\other redirect www.example.com:8080\gui . and possible mask name example.com\other ? as said, i've enabled mod_proxy use proxypass , proxypassreverse this first try proxypass proxypass /foo http://domain.com:5780 proxypassreverse /foo http://domain.com:5780 when tried access http://myown.com/foo redirected domain selected did not loaded images, did not saw before because images @ page bottom. i have read page mod_rewrite, mod_alias, redirect , mod_proxy, i've edited apache config , it's not working properly. the answer depends on application running on port 8080. if it's java application running under tomcat, consider mod_jk if it'...

Rails 4 file uploads -

i using file_field helper upload file. following file upload. works fine upload file, post-upload additional processing. that, need know source path, ie full local file path, can use upload additional files without use of form. ideas on how should go doing this?

osx - How do I change the starting screen size in Cocos2d-x 3.1 for Mac target? -

my app supposed run in portrait. ios specify in plist file. android it's in manifest. when try run mac app launches in landscape, though it's supposed in portrait. i've tried find mainmenu.xib file specified in mac plist via xcode search, in 3.1 project, there wasn't 1 able found. tried looking through mac specific files under platform->mac didn't see related screen sizes. edit update: in addition @gamedeveloper answer, made following changes: if( !glview) { #if (cc_target_platform == cc_platform_mac) glview = glview::createwithrect("myapp", rect(0,0, 640, 960)); #else glview = glview::create("myapp"); #endif } it should noted supplied rect ideally design size. there no xib or nib. in v 3.0 in main.cpp should have: int main(int argc, char *argv[]) { appdelegate app; eglview eglview; eglview.init("hello world",900,640); return application::getinstance()->run(); } change 9...

vba - Bizarre blue box of death - Visual Basic - Excel -

Image
please see picture below.essentially, without action on part, in vba project box in top left, see identical blue box spreadsheets, every tab in workbook. accompanied catastrophic failure error , can no longer run of procedures. has seen before? does know i'm unintentionally doing cause this?

javascript - Add new ID for every new loop -

i'm developing sort of loop using li tags. loop, i'm going use text gonna displayed through simple open , close javascript code i've made when clicking somewhere. guys know, kind of code manipulated through getelementbyid property. however, since i'm going loop these lists items, cannot repeat ids throughout them. so, how can loop these list items without repeating id? take html below: <section class="pro-further"> <span>consulte</span><br> <ul> <li><div onclick="furtherinfo('test');">info one</div> <div id="test">text first info</div> </li> <li><div>info two</div> <div>text second info</div> </li> <li><div>info three</div> <div>text third info</div> </li> <li><div>info four</div> <div>text fourth info</di...

ios - UIImagePickerController ImageIO_PNG takes massive memory -

although resize images once uiimagepickercontroller has finished taking photo, instruments profile says calls imageio_png taking massive amounts of memory (40 mb+) each time take photo. code: - (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { @autoreleasepool { if (myimageview.image == nil) { myimageview.contentmode = uiviewcontentmodescaleaspectfill; uiimage *topimage = [info objectforkey:@"uiimagepickercontrolleroriginalimage"]; uiimage *image = [info objectforkey:uiimagepickercontrolleroriginalimage]; cgrect rect = cgrectmake(0,0,320,440); uigraphicsbeginimagecontext( rect.size ); // use local image variable draw in context [topimage drawinrect:rect]; uiimage *topresized = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); myimageview.image = t...