Posts

Can I add admin links with dynamic JavaScript from my controller in CodeIgniter 2? -

i want cache of controllers’ output, of pages need have links can add , edit info. if set “js” controller , routed “global.js” “global” method of “js” controller, couldn’t use php dynamically add javascript “global.js” if i’m logged in admin? there better way cache pages if visitor not admin? i want show add/edit/delete links on page, if i'm logged in admin. want cache page. codeigniter's caching doesn't support conditional caching, needed workaround insert links dynamically. i'm using php dynamically write javascript can use jquery insert links. 1) set in /config/routes.php: $route['js/global.js'] = 'js/global_scripts'; // function can't called "global" since it's php keyword 2) have function in js controller: public function global_scripts() { $this->output->set_header("content-type: application/x-javascript") $this->load->view('js/global'); // see below } // global_scripts ...

facebook - How do you load third party package in Codeigniter? -

this elementary question. i downloaded facebook php sdk , stored in "third_party" folder within codeigniter. hoping should go. how load such php sdk? thanks i ended sticking in in ci's libraries directory , adding libraries autoload in config/autoload.php autoload.php: $autoload['libraries'] = array('facebook'); then, made small change facebook implementation (constructor of facebook class) , added keys app's config file: public function __construct() { $ci =& get_instance(); $this->setappid($ci->config->item('fb_appid')); $this->setapisecret($ci->config->item('fb_secret')); $this->setcookiesupport($ci->config->item('fb_cookie')); $this->setbasedomain($ci->config->item('fb_domain')); $this->setfileuploadsupport($ci->config->item('fb_upload')); } ...and presto - have access facebook's api in models , controller...

String variables in python function? -

i'm writing script in python, not able use multiple stings in cases check directory, file creation etc, i'm using user input : drive = raw_input('enter drive name make backup ') if not os.path.exists('/media/%s/backup' %drive): os.mkdir('/media/%s/backup' %drive) the above code working, tarfile below giving error........ ./backup4.py enter drive name make backup pendrive traceback (most recent call last): file "./backup4.py", line 17, in <module> tarfile = tarfile.open("/media/%s/backup/%s.tar.bz2" %drive %datevar, 'w:bz2') typeerror: not enough arguments format string tarfile = tarfile.open("/media/%s/backup/%s.tar.bz2" %drive %datevar, 'w:bz2') what changes should make above tarfile.open?? your string formatting incorrect. need pass tuple of variables equal amount of substitutions in string. tarfile = tarfile.open("/media/%s/backup/%s.tar.bz2" % (drive,...

scala - Method return type covariance -

how can define method returns list[+anyref]? tried: def a[t <: anyref](): list[t] = list[anyref]() but reason not compile. edit : according wong should use def a[t <: anyref](): list[t] = list[t]() but there way able return subtype of anyref, example def a[t <: anyref](): list[t] = if (value) list[t]() else list[option[string]]() here option[string] descendant of anyref, compiler not accept it so main question if can declare method covariant return type list[+anyref] let's make couple observations , experiment few ways of letting compiler decide on return type: 1) notice statement if (value) list[t]() else list[option[string]]() returns 2 different specific types if statement must return same type , else clauses. when statement returns value, compiler need infer general type 2 clauses bring in consistent constraint. 2) notice type variable t dependent on exact type pass in when call a() , example a[scala.io.source]() . in method decla...

php - How to access a constant from within a class method -

i'm migrating php application procedural oop. use debug constant activate errors , warnings output (in fact, have thee, every 1 makes output more verbose. can't find way access constants within method. constants defined before autoload in separate file. in utility file have define('debug', true); and inside given method tried if(!defined('debug')) define('debug', false); but end debug=false. doing wrong? i'm total noob oop, gentle please :-) clarification every class has own file. in given script, first thing include utility file. utility file 1 defines debug , has _autoload function. script_file.php includes utility_file.php defines debug has _autoload function according this , should access debug (no prepending $) in code directly. including or requiring utility file in same file has function you're talking about? don't think oop problem

java - The composite pattern/entity system and traditional OOP -

Image
i'm working on small game written in java (but question language-agnostic). since wanted explore various design patterns, got hung on composite pattern /entity system (which read here , here ) alternative typical deep hierarchical inheritance. now, after writing several thousand lines of code, i'm bit confused. think understand pattern , enjoy using it. think it's cool , starbucks-ish, feels benefit provides short-lived , (what irks me most) heavily dependent on granularity. here's picture second article above: i love way objects (game entities, or whatever want call them) have minimal set of components , inferred idea write code looks like: baseentity alien = new baseentity(); baseentity player = new baseentity(); alien.addcomponent(new position(), new movement(), new render(), new script(), new target()); player.addcomponent(new position(), new movement(), new render(), new script(), new physics()); .. nice... in reality, code ends looking like basee...

powershell - Pscx.IO.PscxPathInfo -

i trying create shortcut using new-shortcut pscx. putting in paths i'm getting pscxpathinfo error ( string cannot converted pscxpathinfo). tried $dest = "...path" - , used "get-item $dest" - nothing helps. can show me example how use new-shortcut? kind regards franz-georg this known bug think oisin has fixed in daily bits e.g. works me: new-shortcut c:\users\keith\desktop\reflector.lnk c:\bin\reflector.exe we need official release out here shortly. fixed quite few bugs since original pscx 2.0 release.