Posts

c - How to display uid, size and file's type? -

i'm using gcc 32bit compiler. used stat() function, not giving information type of file. there function or way find these? i believe looking st_mode member of struct stat. from stat(2) manpage: status information word st_mode has following bits: #define s_ifmt 0170000 /* type of file */ #define s_ififo 0010000 /* named pipe (fifo) */ #define s_ifchr 0020000 /* character special */ #define s_ifdir 0040000 /* directory */ #define s_ifblk 0060000 /* block special */ #define s_ifreg 0100000 /* regular */ #define s_iflnk 0120000 /* symbolic link */ #define s_ifsock 0140000 /* socket */ #define s_ifwht 0160000 /* whiteout */ #define s_isuid 0004000 /* set user id on execution */ #define s_isgid 0002000 /* set group id on execution */ #define s_isvtx 0001000 /* save swapped text after use */ #define s_irusr 0000400 /* read permission, owner */ #define s_iwusr 0000200 ...

angularjs - Can I declare a variable in html? -

given <li>document printing - <a href="http://{{displaysandbox()}}/{{displaycase()}}/printingservice/documentprintingservice.svc"> <span ng-class="{true:'value',false:'invalid'}[(sandbox && validcase())==true]">http://<span class="sandbox">{{displaysandbox()}}</span>.companyname.com/<span class="case">{{displaycase()}}</span>/printingservice/documentprintingservice.svc</span></a> <span ng-bind-html-unsafe="geturl('/printingservice/documentprintingservice.svc')"> </span> </li> i declare wrap in <div ng-var="subpath=/printingservice/printingservice.svc> so inside scope able <li>document printing - <a href="http://{{displaysandbox()}}/{{displaycase()}}{{subpath}}"> <span ng-class="{true:'value',false:'invalid'}[(sandbox && validcase())==true]"...

php - Magento shell command fatal error: Class "Mage" not found -

when run command within /shell/ directory: php -f regularpromos.php why receive error? php fatal error: class 'mage' not found in /var/www/vhosts/yoohoo/httpdocs/shell/regularpromos.php on line 28 this regularpromos.php: <?php require_once 'abstract.php'; class mage_shell_regularpromos extends mage_shell_abstract { //day of week repeat promotion protected $day; //id of promotion protected $promoid; //rule process object protected $rule; public function mage_shell_regularpromos($promoid, $day) { $this->day = $day; $this->promoid = $promoid; $this->rule = mage::getmodel('salesrule/rule'); } public function run() { date_default_timezone_set('america/new_york'); $nextweek = date('y-m-d', strtotime('next '. $this->day)); $rule = $rule->load($this->promoid); $rule->setfromdate($nextweek) ...

php - Unable to generate route value_user_create -

i have problem symfony2-project sonataadmin- , userbundle. installed , configured according both admin- , userbundle-documentations , tried running, seems fine start. can both bundles come out-of-the-box. when try access list of users admin-dashboard (default path /admin/sonata/user/user/list ), this: an exception has been thrown during rendering of template ("unable generate url named route "value_user_create" such route not exist.") in "sonataadminbundle:crud:list.html.twig". as described, neither did change default routing informations provided sonata, nor did overwrite controller or anything. according symfony console router:debug route admin_sonata_user_user_create , amoungst other crud-routes, exists (pointing /admin/sonata/user/user/create ) so me seems value in route-name value_user_create not replaced admin_sonata_user -prefix, that's thought , cannot prove it. anyways can't find place fix problem, every , tip might helpful her...

java - Using JSoup to parse text between two different tags -

i have following html... <h3 class="number"> <span class="navigation"> 6:55 <a href="/results/result.html" class="under"><b>&raquo;</b></a> </span>**this text need parse!**</h3> i can use following code extract text h3 tag. element h3 = doc.select("h3").get(0); unfortunately, gives me in tag. 6:55 &raquo; text need parse! can use jsoup parse between different tags? there best practice doing (regex?) (regex?) no, can read in answers of this question , can't parse html using regular expression. try this: element h3 = doc.select("h3").get(0); string h3text = h3.text(); string spantext = h3.select("span").get(0).text(); string textbetweenspanendandh3end = h3text.replace(spantext, "");

excel - save global variables in spreadsheet -

i have module load of global variables. name of global variables in module saved in first column, , global variable value saved in second column i.e public variable1 string public variable2 string public variable3 string variable1 = david variable2 = chicken variable3 = apple column a: variable1, variable2, variable3 column b: david,chicken,apple i can think of 3 ways go this. you set global variables properties , have thier values stored in cells on worksheet. execution of code slower, values persist , viewable/editable on spreadsheet. for example, define string property 'foo' acts global variable put in global module: public property foo() string foo = debugsheet.[b2] end property public property let foo(value string) debugsheet.[b2] = value end property you use named ranges globals, eg debugsheet.[foo] a third way have hardcoded save , load routines explicitly save each global specific cell in spreadsheet. works if save routine has run sinc...

java - Does a binary tree contain another tree? -

alright guys, asked question in interview today , goes this: "tell if 1 binary tree contained inside binary tree or not (contains implies both in structure , value of nodes)" i thought of following approach: flatten larger tree as: {{{-}a{-}}b{{-}c{-}}}d{{{-}e{{-}f{-}}}g{{{-}h{-}}i{{-}j{-}}}} (i did write code this, {-} implies empty left or right sub-tree, each sub-tree enclosed within {} paranthesis) now smaller sub-tree need match pattern: {{.*}e{.*}}g{{{.*}h{.*}}i{{.*}j{.*}}} where {.*} denotes empty or non-empty sub-tree. at time thought, trivial regex pattern matching problem in java bamboozled. feel, have transformed problem (created 1 monster out of another). is there simple regex 1 liner match these patterns? understand there might other approaches solve problem , might not best one. wonder if solvable. i'm not sure interviewer meant "contained inside binary tree". if interviewer asking method check whether subtree of...