Posts

Showing posts from May, 2015

php - Use Loader class within a hook in CodeIgniter -

i have function in hook: public function checkiflogged() { $this->ci = & get_instance(); if(!$this->ci->session->userdata('logged') ){ $this->ci->load->view('common/home'); exit; } } my problem $this->ci->load->view('common/home'); doesn't load template file @ all. there resons why? i using post_controller_constructor hook. thanks, peter pre_system called during system execution. benchmark , hooks class have been loaded @ point. no routing or other processes have happened. pre_controller called prior of controllers being called. base classes, routing, , security checks have been done. post_controller_constructor called after controller instantiated, prior method calls happening. post_controller called after controller executed. display_override overrides _display() function, used send finalized page web browser @ end of system execution. permits use own disp

r - Multiple outputs from single menu -

suppose have data frame this: class sex score m 90 f 90 f 85 m 85 m 80 m 70 f 70 m 60 b f 90 b m 90 b m 75 b f 70 and want single menu selects class , sex , gets average. right on real data frame i'm using 2 menus i <- menu(c("a","b"), graphics=true, title="choose class") j <- menu(c("m","f"), graphics=true, title="choose sex") df.1 <- df.1[df.1$class==i, ] df.1 <- df.1[df.1$sex==j, ] but when there many more variables class , sex seems annoying click multiple menus when selected in 1 window. possible in r ? this modified basic idea create intersection of of options show , use single menu. dat <- read.table(textconnection("class sex score m 90 f 90 f 85 m 85 m 80 m 70 f 70 m 60 b f 90 b m 90 b m

c++ - Compiler Libraries vs. Operating System Libraries -

i noticed both compiler ( mingw ) , windows 8 sdk come same libraries, save naming conventions (i.e. win32.lib on windows 8 sdk libwin32.a in mingw libraries). do compilers come libraries such these? are these libraries multiple operating systems? what difference (if any) between libraries come windows 8 sdk , come compiler? there 2 kinds of libraries: import libraries: these libraries list find references variables/functions/etc., don't contain code itself. "normal" libraries (which contain object files contain machine code): these libraries contain object files, contain actual machine code. the libraries ship operating system import libraries. actual code, after all, in operating system itself; import libraries merely tell how use code provided in operating system. why necessary? because there no way program "discover" libraries available on operating system while running , program has know available when compiled . those

java - I need a way to manipulate the last character in a JTextArea (by deleting it) -

i have jtextarea can fill text using jbuttons. want jbutton can use backspace without using robot class or backspace key, clicking button on screen mouse. how manipulate text using public void actionperformed(actionevent e) { of jtextarea using button, using self-created backspace key? let me know if have questions or confused on i'm asking. take @ document . every text component in swing has document model controls state of text (and applicable, attributes , structure). you can use jtextarea 's document remove characters directly. something like... document doc = textarea.getdocument(); doc.remove(doc.getlength() - 2, 1);

php - csv file requires to open and save again in order to display data. -

i exporting csv file server , using php script fetch data csv , show on webpage. now it's working good. but problem have open exported csv file first , copy paste date csv file. it not fetching data exported file straight away. it's weird, said when copy data , provide same name csv file, same, works. why that. php function(although don't think there problem that) public function import(){ $fp = fopen(data_path.'/testfile.csv', 'r'); // first (header) line $header = fgetcsv($fp); // rest of rows $data = array(); while ($row = fgetcsv($fp)) { $arr = array(); foreach ($header $i => $col) $arr[$col] = $row[$i]; $data[] = $arr; } $all = $data; $soldval=array(); foreach ($all $key=>$value){ $sold = $value["total_qty_ordered"]; array_push($soldval, $sold); } print_r($soldval); //echo '<br/>'; $totalseats = i

javascript - Twitter Bootstrap (and similar CSS frameworks) folder location -

what pros , cons of putting bootstrap folder official bootstrap distribution in css or styles folder of app, vs. putting in more generic assets directory or top-level folder directly beneath public or www ? since bootstrap concerned css, initial inclination put in css folder, has images , javascript i'm not sure if that's best place it. javascript included bootstrap, it's visually oriented perhaps keeping in css folder still makes sense. it's obvious question isn't specific bootstrap, relevant css-oriented framework type of structure, example: http://jslegers.github.io/cascadeframework/ . my goal keep things easy work both me , other programmers new app. there other factors beyond deciding on logical location should consider? example how folder structure might impact livereload less or sass files (especially if wanted extend bootstrap classes using less)? you might want consider yeoman manages that. http://yeoman.io/

What select statement can I use to determine 1) the roles that a user belongs to and 2) the tables that a user has access to using PostgreSQL? -

using psql, \dg , \du tells me roles each user (role) belongs to. want determine programmatically single user cannot find system tables used generate results returned \dg . need special privileges execute query? as related question, want determine tables role can update. i've read documentation on create role , grant , surrounding documentation tell me how set roles , privileges, not how test role membership or table access privileges. there built-in system information functions both. see pg_has_role , etc. you can query the information_schema role membership data, in particular information_schema.applicable_roles , information_schema.enabled_roles , information_schema.administrable_role_authorizations . finally, psql \d command can find out psql doing information running psql -e option print sql runs. don't recommend using psql 's sql when there's builtin function or information_schema view same information though. psql 's approach m

Open file and with statement in Python -

i have function like: def func(filename): open(filename) f: return [line.split('\t')[0] line in f] is "with" statement closing file when there 'sudden' function return? can ignore "with" statement? i.e. safe , equivalent (from memory leak perspective) do, def func(filename): return [line.split('\t')[0] line in open(filename)] ? it's safe. context manager's __exit__ called if return while inside of context, file handle closed. here's simple test: class contexttest(object): def __enter__(self): print('enter') def __exit__(self, type, value, traceback): print('exit') def test(): contexttest() foo: print('inside') return when call test() , get: enter inside exit

SQL Server : computed column error in dateadd formula -

these columns (simplifying): mydate date themonths int then create computed column finaldate in microsoft sql server management studio 2008 r2, formula: (dateadd(month, themonths, mydate)) very simple. there error: error validating formula the error occurs if insert formula through integrated assistant in management studio. not occurs when create column through t-sql query. if change mydate type datetime , there's no error, can't change table structure. i try this: (dateadd(month, themonths, convert(datetime, mydate))) the error persists. i created column directly in t-sql using following: add [finaldate] (dateadd(month,[themonths],[mydate])) persisted it works fine, column created, data computed when insert-update. problem in management studio. try 1 - create table dbo.[test] ( mydate date not null default (getdate()), themonths int not null default ((0)), finaldate (dateadd(month, themonths, mydate)) persisted ) inse

javascript - Failed with: Uncaught Tried to save an object with a pointer to a new, unsaved object -

i having error, , cloud code. var highscore = parse.object.extend("highscore"); highscore = new highscore(); highscore.set("totalxp", request.params.totalxp); highscore.set("regionid", request.params.regionid); var relation = highscore.relation("userid"); relation.add(request.user); highscore.save(); response.success(highscore); the response returned empty, weird thing is, relation added when @ data browser. can't find solid answer or explanation. please help. i referred here , , modified code it. reason because put creating object , adding relation in 1 save() operation. var highscore = parse.object.extend("highscore"); highscore = new highscore(); highscore.set("totalxp", request.params.totalxp); highscore.set("regionid", request.params.regionid); highscore.save(null, { success: function(savedhighscore){ var relation = savedhighscore.relation("userid");

c# - Errors in App.xaml trying to use MVVM Light in Windows Phone 8 project -

when add mvvm light package via nuget errors referencing lines in app.xaml file added during install. these errors appear in windows phone 8 projects. exact same lines in windows phone 7 project not raise errors. mvvm light added lines are: <resourcedictionary> <vm:viewmodellocator x:key="locator" d:isdatasource="true" /> <resourcedictionary.mergeddictionaries></resourcedictionary.mergeddictionaries> </resourcedictionary> these lines positioned before ending </application.resources> tag. errors reported in error list pane are: each dictionary must have associated key the name "viewmodellocator" not exist in namespace "clr-namespace:sdkvoicealarmclockwp8cs.viewmodel" this seems make sense since <resourcedictionary> tag not have key attribute. however, if try move block of lines outside block, whole new set of errors. as far viewmodellocator problem concerned, double-checked

How do you serve a file for download with AngularJS or Javascript? -

i have text in hidden textarea. when button clicked have text offered download .txt file. possible using angularjs or javascript? you can using blob . <a download="content.txt" ng-href="{{ url }}">download</a> in controller: var content = 'file content example'; var blob = new blob([ content ], { type : 'text/plain' }); $scope.url = (window.url || window.webkiturl).createobjecturl( blob ); in order enable url: app = angular.module(...); app.config(['$compileprovider', function ($compileprovider) { $compileprovider.ahrefsanitizationwhitelist(/^\s*(https?|ftp|mailto|tel|file|blob):/); }]); please note each time call createobjecturl(), new object url created, if you've created 1 same object. each of these must released calling url.revokeobjecturl() when no longer need them. browsers release these automatically when document unloaded; however, optimal performance , memory usage, if there

c# - Error In Visual Studio 2012 architecture Code Generate With T4 -

Image
i use vs2012 design uml diagram , use t4 generate custom class , interface. and use tfs source controler. but since yesterday i'm getting error , codes not generated. 5/13/2013 8:18:59 am: code generation or text transformation started. 5/13/2013 8:19:51 am: errors encountered in 'classtemplate.t4' while generating code 'andish.css.modeling.umldiagram::model::andish.css.domain::businessdomain::calculator::grou pprecalculatingresult' - (class). 5/13/2013 8:19:58 am: code generation complete. errors: 1. warnings: 0. 5/13/2013 8:19:58 am: unable write log file: f:\andish\andishmandframwork\modeling\andish.css.modeling.umldiagram\codegeneration.log.xml - access path 'f:\andish\andishmandframwork\modeling\andish.css.modeling.umldiagram\codegeneration.log.xm l' denied. this pic vs2012 and 1 error down : error 44 errors generated when initializing transformation object. transformation not run. following excepti

xcode - Dropdown UIView inside UITableView Section Headers -

Image
i need add customised dropdown uiview uitable section header part of design requirements. have added the dropdown uiview section header when try click on title inside dropdown, wouldn't recognise have make selection on dropdown uiview, instead fire off didselectrowatindexpath of big uitableview underneath. seems can't make selection of items display outside section header height if it's added section header. i'm not using uitableview popup uiview. each row uibutton , attached touch inside event listener. when try click on buttons, wouldn't detect clicked on buttons take i've clicked on cupertino. tag attached each each button. this example of how handle event. -(ibaction)menubuttonpressed:(uibutton *)sender { [sender setselected:!sender.isselected]; switch (sender.tag) { case 0: #do break; case 1: #do break; } } when try expand section header height, buttons fall in

xna - Rotate the least amount with two vectors -

Image
i've gone through lot of questions online last few hours trying figure out how calculate rotation between 2 vectors, using least distance. also, difference between using atan2 , using dot product? see them often. the purpose rotate in y axis only based on differences in x/z position (think top down rotation in 3d world). option 1: use atan2. seems work well, except when switchs radians positive negative. float radians = (float)math.atan2(source.position.x - target.position.x, source.position.z - target.position.z); npc.modelposition.rotation = new vector3(0, npc.modelposition.rotation.y + (radians), 0); this works fine, except @ 1 point starts jittering swings other way. use dot product. can't seem make work well, turns in same direction - possible swing in least direction? understand ranges 0 pi - can use that? float dot = vector3.dot(vector3.normalize(source.position), vector3.normalize(target.position)); float angle = (f

php - New mysqli connection is not working in My Cpanel but works in my computer -

this question has answer here: access denied user @ 'localhost' database '' [closed] 2 answers php code functioning in computer whenever uploading files cpanel not working receiving error message: warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1044): access denied user '*****'@'localhost' database '*****' in /home/*****/public_html/admin panel/db.php on line 3 unable connect database [access denied user '*****'@'localhost' database '*****'] my username , password both 100% correct don't know why receiving this. <?php $connection=new mysqli('localhost', 'cpanelname_username', 'test.123', 'cpanelname_db'); if($connection->connect_errno > 0){ die('unable connect database [' . $connection->connect_error . ']'

ios - Non-PIE Binary Livecode mergExt -

i´ve sent update of ios app developed livecode time update rejected apple saying app "is not position independent executable. please ensure build settings configured create pie executables." do know how problem fixed? thanks try build application loader @ following location: https://devnet.madewithmarmalade.com/questions/9692/ios-app-rejected-with-non-pie-binary-error.html

android - java.lang.NoClassDefFoundError Proguard - unable to resolve virtual method -

in main class in application i'm handling api variations programmatically: private static bluetoothheadset mbluetoothheadset; // later in code if (build.version.sdk_int >= build.version_codes.honeycomb) { mbluetoothheadset = proxy; } i assumed noclassdeffounderror caused because declaring variable bluetoothheadset api 11, app available api 9. thinking being clever , not directly referencing missing class, therefore parameterized it: private static object mbluetoothheadset; // later in code if (build.version.sdk_int >= build.version_codes.honeycomb) { mbluetoothheadset = (bluetoothheadset) proxy; } but didn't work , i'm wondering if proguard obfuscation culprit: could not find class 'com.package.name.qc', referenced method com.package.name.example.<init> vfy: unable resolve virtual method 435: landroid/bluetooth/bluetoothheadset;.startvoicerecognition (landroid/bluetooth/bluetoothdevice;)z during o

android - service that gets registered with service manager -

i did tried sample code service , installed same on device , started app. tried list service adb command, running (could see logs same in logcat) adb shell service list but, above command lists system service , not see service listed there. so, question, 1. services need register service manager or "system services" 2. if have aidl implemented same service behave system service (i mean, displayed command "adb shell service list") thanks reading , appreciate response question -regards, manju android system services different sort of services create within app. don't need worry don't appear within adb shell service list . system services provided in rom of phone , core parts of android os, example "surface flinger" (graphics compositor), "package manager" etc. accessed within android frameworks typical android application developer never contacts them directly. looked based on simple string. normal services inhe

c++ - Modifying pointer value -

i having trouble work assigned schooling. told write program modifies char. can fine. cannot how work pointers. i've researched this, , found solutions. don't meet assignment's needs. told define function this: int stripwhite(char *userinput) so did. problem is, believe makes copy of value. , not modify actual value. here code picked out of program: inside main, declare char, , use cin.getline collect input. call stripwhite. cout char. value never changes. assignment says stripwhite needs defined above. @ lose here. help? char userinput[100]; int spaces = 0; cin.getline(userinput,99); spaces = stripwhite(userinput); cout << userinput; your function takes character pointer. based on function name , usage, function presumably intended take character buffer input , remove spaces while returning number of spaces removed. so basically, have iterate through buffer, , move down contents while skipping spaces. easiest way maintain 2 pointers , copy 1 ot

c++ - Stringstream error: cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' -

in creating simple exception class extension (where can construct error messages more easily), i've isolated error down following simple code: #include <sstream> #include <string> class mycout { public: std::stringstream ssout; // removing gets rid of error template <typename t> mycout& operator << (const t &x) { // formatting return *this; } }; class myerr : public mycout { public: using mycout::operator<<; }; int main(int argc, const char* argv[]) { throw myerr() << "errormsg" << 1; mycout() << "message formatted"; return 0; } which, on compiling, produces error: 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\sstream(724): error c2248: 'std::basic_ios<_elem,_traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_elem,_traits>' 1> 1> [ 1>

Is it possible to read Word files (.doc/.docx) in Python -

i want create validation tool; can 1 me read .doc/.docx documents in python in order search , compare file contents. yes possible. libreoffice (at least) has command line option convert files works treat. use convert file text. load text file python per routine manoeuvres. this worked me on libreoffice 4.2 / linux: soffice --headless --convert-to txt:text /path_to/document_to_convert.doc i've tried few methods (including odt2txt, antiword, zipfile, lpod, uno). above soffice command first worked , without error. this question on using filters soffice on ask.libreoffice.org helped me.

javascript - Array being sent as String on node.js -

i doing experimenting socket.io. have canvas sends data server receives fine. it receives uint8clampedarray correct because being sent. when .send message server client, string: [object object]. again have checked! missing something, code server below: var fs, http, io, server; fs = require('fs'); http = require('http'); server = http.createserver(function(req, res) { return fs.readfile("" + __dirname + "/front.html", function(err, data) { res.writehead(200, { 'content-type': 'text/html' }); return res.end(data, 'utf8'); }); }); server.listen(1337); io = require('socket.io').listen(server); io.sockets.on('connection', function(socket) { socket.on('publish', function(message) { return io.sockets.send(message); }); }); on client: var datastr = json.stringify(data); // converts object string on server: var dataobj = json.

jquery - Unable to send JSON data to server from javascript -

i need send json data server method. this method works when pass simple 'test' string, not 1 follows: function sendtoserver() { $.ajax({ type: "post", url: "default.aspx/saveclientgrid", data: "{ griddata: 'test' }", contenttype: "application/json; charset=utf-8", datatype: "json" }); } doesn't work: function sendtoserver() { var data = json.stringify(datasource); $.ajax({ type: "post", url: "default.aspx/saveclientgrid", data: "{ griddata: " + data + " }", contenttype: "application/json; charset=utf-8", datatype: "json" }); } figured it, 1 works: function sendtoserver() { var data = json.stringify(datasource); $.ajax({ type: "post", url: "default.aspx/saveclientgrid", data: "{ gri

multithreading - C# Catching Exception From Invoked Delegate on another Thread -

i have code follows. running on "thread 2" webbrowser browser = this.webbrowser browser.invoke(new methodinvoker(delegate { browser.document.getelementbyid("somebutton").invokemember("click"); })); thread.sleep(500); browser.invoke(new methodinvoker(delegate { browser.document.getelementbyid("username").setattribute("value", username); })); //folowed several more similar statments essentially invoking methods on webbrowser control created on different thread, "thread 1". if element on current page loaded in browser not contain element "somebtn" or "username", exception thrown "thread 1". is there way catch exception on "thread 2"? know use try catches within delegates , have special delegate returns value(like exception), there way around options? note*: require thread.sleep particular page requires delay between events. if there way combine these events single delegate

reflection - synthetic static fields in java with type "java.lang.Class" -

i saw synthetic fields in class org.jfree.data.time.regulartimeperiod, , have no ideas , for. use code find them out: for (field f : regulartimeperiod.class.getdeclaredfields()) if (f.issynthetic()) system.out.println(f); and give these: static java.lang.class org.jfree.data.time.regulartimeperiod.class$java$util$date static java.lang.class org.jfree.data.time.regulartimeperiod.class$java$util$timezone static java.lang.class org.jfree.data.time.regulartimeperiod.class$org$jfree$data$time$year static java.lang.class org.jfree.data.time.regulartimeperiod.class$org$jfree$data$time$quarter static java.lang.class org.jfree.data.time.regulartimeperiod.class$org$jfree$data$time$month static java.lang.class org.jfree.data.time.regulartimeperiod.class$org$jfree$data$time$day static java.lang.class org.jfree.data.time.regulartimeperiod.class$org$jfree$data$time$hour static java.lang.class org.jfree.data.time.regulartimeperiod.class$org$jfree$data$time$minute static java.lang.class

USB LED Light handling using Java -

Image
i have usb led light, can 1 give piece of code can turn on or off usb light? it turns on when plug usb port, know, possible control light using java.(just fun). to turn off: sudo shutdown -h to turn on: just power on pc

android market app is not available list of default applications -

i trying run android on emulator. not find "android market" app in default app list of emulator. tried download google play requires have "google play app" in default list, not available in emulator. tried search downloading apk file "android market" on net, install it. not find reliable source downloading that. if suggest me way of installing app, thankful you. please tell me download link downloading android apps. first of need know .apk files can't downloaded google play. files installed directly supportive device. secondly emulator can't have play store app. so, if want install .apk files on emulator, first download .apk torrent(famous .apk files available there) use adb tool push .apk file on emulator. google "how install apk on emulator" find many option use adb push emulator. may helps you, enjoy android on emulator. :)

qt4 - Getting focus/activeFocus status from QML ListView -

i've 2 column layout listview in left column. left/right keys can change focus between 2 parts of app. the active focus of left column delegated listview , there straight 1 of it's rows. how can check whether listview or 1 of it's children has focus? import qtquick 1.1 focusscope { width: 960 height: 540 id: app focus: true focusscope { id: leftcolumn keynavigation.right: rightcolumn anchors.bottom: parent.bottom anchors.left: parent.left anchors.top: parent.top width: 250 focus: true rectangle { id: leftbackgroundcolor anchors.fill: parent color: contactslist.activefocus ? "red" : "#e6e6e6" listview { id: contactslist interactive: true anchors.fill: parent focus: true delegate: text { text: name

Make an sprite transparent in COCOS2D iPhone -

i want make sprite transparent. let me give example want implement. let's have 1 bubble image , 1 creature image. want make illusion creature in in bubble. can setting z index of sprites , setting opacity of bubble? i can't see why wouldn't work, have set opacity , zorder properties of sprites...

linux - How to convert decimal to hex in bash? -

this question has answer here: convert decimal hexadecimal in unix shell script 9 answers i have decimal number in bash shell: linux$ a=67 how print 67 hexadecimal in bash? as bash program: #!/bin/bash decimal1=31 printf -v result1 "%x" "$decimal1" decimal2=33 printf -v result2 "%x" "$decimal2" echo $result1 $decimal1 echo $result2 $decimal2 or directly bash shell: el@defiant ~ $ printf '%x\n' 26 1a el@defiant ~ $ echo $((0xaa)) 170 el@defiant ~ $

ruby on rails - How can I call text_field_tag with an array? -

consider this: text_field_tag :phone, :class => "input span2", :id=>"follow_up_phone" however, if have arguments in array: [:phone, {class: "input span2", id: "follow_up_phone"}] how call text_field_tag using array? text_field_tag array doesn't seem work first of all: where's value? signature is: text_field_tag(name, value = nil, options = {}) so, have call way: text_field_tag :phone, nil, :class => "input span2", :id=>"follow_up_phone" ^ and array has be: [:phone, nil, {class: "input span2", id: "follow_up_phone"}] use splat operator pass array: text_field_tag *array

jquery - nested tables, remove inner table containing pattern -

i have again issue scoping (i guess). want write generic possible function retrieve page , remove of code before set content placeholder ( <div> ) below sample code of loading page: <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>testtesttest</title> </head> <script type="text/javascript" src="/ajax/jquery-1.6.4.min.js"></script> <script type='text/javascript' src='/util.js'></script> <body> <div class='contentcontainer'> <hr> <div class='contentitem' id='restart' style="margin-top: 100px; margin-left: 100px; margin-bottom: 100px; display:block;"> <table> <tr> <td><img src='/images/warn__xl.gif'></td> <td><p style="font-size: 1.2em; font