Posts

Showing posts from February, 2014

javascript - Dropdown menu bootstrap multilevel -

Image
i have question: how make navbar text in left in bootstrap? i'd make dropdown menu bootstrap , jquery-menu-aim. dropdown submenu piled up. goal is. and i've done.. can me? in advance. i'm using bootstrap 3.3.4. html file <header> <div class="branding">logo <h3>brand</h3> <!--<div style="clear: both;"></div>--></div> </header> <nav role="navigation" class="navbar navbar-fixed-top"> <div class="container"> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="navbar-left"> <a href="index.html" class="dropdown-toggle" data-toggle="dropdown">product</a> <ul class="dropdown-menu" role="menu"> <li class="search row-sm-3"> ...

javascript - JQuery .click event won't turn back on -

i created panel (div) slides in , out of nav bar. right now, it'll open , close once fine won't respond clicks anymore. $('.work-link').mouseover(function(){ if($('.work-link').css('left') === '0px') { $('.work-link').off('click'); } else if($('.work-link').css('left') === '-750px') { $('.work-link').on('click'); }; }); $('.work-link').on('click', function(){ $('.work-link').animate({left: '0px'}, 600); $('.work-link').css('cursor', 'default'); $('.sort-container').animate({marginleft: '0px'}, 800); $('.exit-sort').fadein(600); $('.port-type').animate({marginright: '140px'}, 600); $('.port-type').text("click x close").fadein(); }); $('.exit-sort').on('click',function(){ $('.work-link...

osx - How to copy input from from the clipboard using pbcopy and setting that to another file that can then be called by pbpaste -

i want data main clipboard onto own file when user executes command can retrieve information set upon second file. alternatively pbcopy direcly second file , run command pbpaste . smarter me tell me how this. have searched hours now. pbpaste reads clipboard/pasteboard , writes stdout (as if pasting), can copy pasteboard file using pbpaste > filename . can whatever want file. pbcopy puts onto pasteboard, if want put file's contents pasteboard can pbcopy < filename . the < , > operators shell redirection operators, can learn more in command-line or unix tutorial.

python - How do I loop through each string in my list? -

i tried piece of code, performs function on first string in list: returns first , last 2 characters of given list of strings def both_ends(list): finallist = [] s in list: if s > 2: return s[0] + s[1] + s[-2] + s[-1] else: return s finallist.append(s) return finallist list = ('apple', 'pizza', 'x', 'joke') print both_ends(string) how make function run through of strings in list? yes, because returning result directly , returns after go through first string itself. instead should put result in finallist create , return result @ end. and other things - as said in other answer, want check length of string. the length of string should greater 4 , otherwise, end adding characters multiple times. do not use names list variables, ends shadowing builtin functions , not able use list() create list after that. last issue should call function list, not string . example - ...

math - Factoring fractions in sympy -

how ask sympy factor x**2 - 3/2*x + 1/2 (x-1)*(x-1/2)? closest i've gotten is: >>> (x**2 - rational(3/2)*x + rational(1/2)).factor() (x - 1)*(2*x - 1)/2 a simple way: in [1]: expr = (x**2 - rational(3/2)*x + rational(1/2)) in [2]: expr out[2]: 2 3*x 1 x - --- + - 2 2 in [3]: fe = factor(expr) in [4]: fe out[4]: (x - 1)*(2*x - 1) ----------------- 2 in [5]: fe.args out[5]: (1/2, x - 1, 2*x - 1) in [6]: fe.args[0]*fe.args[2]*fe.args[1] out[6]: (x - 1)*(x - 1/2) that is, factor expression [3] , product arguments [5] , , multiply them [6] . multiplication in step [6] calls evaluation routines simplify expression, not point of expanding it.

C -Element of a structure changes value after printf() call -

[note using c] have issue when call printf twice in row "garbage data" second time. first printf print out "rajan1" expected, , second printf print out random symbols. i'm not sure if random or maybe address. know why might recieving these results? here snippet code highlights problem (not consecutive printf statements: void main(void) { struct listnode **pstart = (struct listnode**) malloc(sizeof(struct listnode**)); load(pstart); printf(" %s\n",*(*pstart)->data->artist); printf(" %s\n",*(*pstart)->data->artist); } as said output expected string first time(it prints "rajan1") , random second time(ussually symbols). have scoured internet similair problem haven't been able find one. searching indicates may need "free" variable have no idea need free, or possibly unique compiler version unsure of(i using whatever default c compiler in visual studio 2012 ultimate v11.0.61219.00 update 5...

r - How to pick the first comma separated value in a column in data.table? -

courtesy of @jaap's answer this stackoverflow question the data this: name text idx c_org 1: john text contains mit 1 mit 2: sussan text stanford university 2 stanford 3: bill graduated yale, mit, stanford. 3 mit,yale,stanford 4: bill text 4 for column c_org , if there's multiple values, in observation 3, mit,yale,stanford , i'd make first value, mit column value. result should this: name text idx neworg 1: john text contains mit 1 mit 2: sussan text stanford university 2 stanford 3: bill graduated yale, mit, stanford. 3 mit 4: bill text 4 (please note in c_org column, field has more 1 value, empty. in expected output, if there's 1 value, keep it...

c# - FileWatcher typicall implementation? -

i building app, watching files. pretty fresh in programming (maybe) have little issue, because dont have real practice. program working, dont know how usally implemented in "real" software. please overview , comment. because have possible in datefiles class , less possible in mainviewmodel. yes app in build on mvvm base. my current state: in mainviewmodel public static string configurationfilessourcepath2; private void initializefiles() { // new instance of datefiles df = new datafiles(); // path datefiles df.configurationfilessourcepath = configurationfilessourcepath; // run initialization method establish "filewatching" df.initializefiles(); // refresh listview in view refreshfilelist(); // assign handler propertychanged event df.propertychanged += df_propertychanged; } // if change inside datefiles private void df_propertychanged(object sender, propertychangedeventargs e) { refreshfilelist(); } // ref...

express - What is meaning of locals in res.render (node.js)? -

what difference between below 2 code block in node.js (express + ejs)? res.render('demo', {locals:{"variable":data}}); and res.render('demo', {"variable":data}); when use one? can 1 please me out in this. the correct way of passing variables view wollowing res.render('demo', {"variable":data}); then have objet res.locals can append data , passed view. for example if have middlewere authentication, can set auth variables before request arrives in route. app.use(function(req, res, next){ res.locals.user = req.user; res.locals.authenticated = ! req.user.anonymous; next(); });

javascript - Bootstrap chosen add new item if no exist -

i trying add new item if not exist. code working dont know how add item directly on list of selected. chosen.prototype.no_results = function(terms) { var no_results_html; no_results_html = $('<li class="no-results">' + this.results_none_found + '"<span></span>" kao' + ' <button class="add" id="interni" class="submit"> interni tip </button> ' + ' <button class="add" id="eksterni" class="submit"> eksterni tip</button> ' + '</li> '); no_results_html.find("span").first().html(terms); no_results_html.find(".add").click(function() { var terms1 = terms + ' (' + this.id + ')'; $('.chosen-select').chosen().append('<option>' + terms1 + '</option>'); $('.chosen-select').chosen().trigger('chosen:updated'); ...

c - Thread-safe global sqlca struct for Oracle database access -

i have multi-threaded (posix thread or pthread based) c application uses oracle pro c precompiler. application uses global sqlca struct. in 1 .c file, includes global sqlca struct definition oracle database access as: #include <sqlca.h> and in other ,c files, uses follows: #define sqlca_storage_class extern #include <sqlca.h> my question if more 1 thread tries access database table query, insert or update , uses global sqlca object, how guarantee mutual exclusion or make thread-safe access? also, when query vs insert / update, use sqlca struct? you have global function grabs mutex object, , global function returns mutex object. the thread needs use database attempts call function grabs mutex. if mutex in use, function returns 0. if mutex available, grab mutex function marks mutex unavailable, , returns 1 success. any subsequent calls grab mutex fail, until thread grabbed mutex calls return mutex function. any thread attempts , fails grab ...

osx - Alien::wxWidgets install fails on OSX10.10 -

i'm trying install alien::wxwidgets version 0.67 wxwidgets version 3.0.2, no matter do, following error: checking if c compiler (clang -mmacosx-version-min=10.5) works sdk/version options... configure: error: in `/users/david/.cpan/build/alien-wxwidgets-0.67-ggkxtu/wxwidgets-3.0.2/bld': configure: error: no. try different sdk see `config.log' more details system: echo exit | sh ../configure --prefix=/users/david/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/darwin-2level/alien/wxwidgets/osx_cocoa_3_0_2_uni --with-osx_cocoa --with-opengl --disable-compat24 --enable-unicode --disable-monolithic --disable-universal_binary --enable-graphics_ctx cc=clang cxx=clang++ cxxflags="-stdlib=libc++ -std=c++11" objcxxflags="-stdlib=libc++ -std=c++11" ldflags=-stdlib=libc++: 256 @ build line 60. i've tried building flags --with-macosx-sdk=10.5, --with-macosx-sdk=10.10, --without-macosx-sdk, --with-macosx-sdk=/applications/xcode.app/contents/devel...

c# - The `Process` does not start with the special characters in the process argument -

i can run ffmpeg.exe -i test.flv -f flv - | ffplay -i - in cmd, can't run in c# codes when "|" in argument. this code works : process process = new process(); process process .startinfo.filename = "ffmpeg.exe"; process process .startinfo.arguments =" -i test.flv " process .start(); but code not working : process process = new process(); process process .startinfo.filename = "ffmpeg.exe"; process process .startinfo.arguments =" -i test.flv -f flv - | ffplay -i -" process .start(); i tried codes did not effect: process process .startinfo.arguments =" -i test.flv -f flv - \| ffplay -i -" process process .startinfo.arguments =" -i test.flv -f flv - \\| ffplay -i -" process process .startinfo.arguments =@" -i test.flv -f flv - | ffplay -i -" process process .startinfo.arguments ="\" -i test.flv -f flv - \| ffplay -i -\"" please tell me how...

javascript - Browser should keep refreshing the iframe -- not working -

i've page shows network status. refreshing self after 1 minute or so. when can't load page display blank page , stays there when load page. to solve i've placed network status page(status.php) within iframe , parent page(index.html) should keep reloading network status page within iframe after 1-2 minutes. i've written code: <!docttype html> <head> <script> console.log("running window.log"); window.setinterval(function(){ reloadiframe(); }, 10000); function reloadiframe() { console.log("reloaded frame"); window.frames[0].location.reload(); } </script> </head> <body> <iframe frameborder=0 name="frame11" width="100%" height="100%" src="status.php"> </iframe> now when disable network connection, page(index.html) going blank showing on chrome: "the internet connection has been lost." message in console: uncaught securityerror: bloc...

ios - How to implement background fetch correctly in ios swift -

i have situation using background fetch call data sync process, sync function heavy task, executed in background thread. here code, func application(application: uiapplication, performfetchwithcompletionhandler completionhandler: (uibackgroundfetchresult) -> void) { print("background fetch") utilities.synccompleted = false // declared :> static var synccompleted:bool = false backgroundsync().startsync() // heavy background task, , iam updating [utilities.synccompleted = true) on thread completion while utilities.synccompleted == false { nsthread.sleepfortimeinterval(1) // sleep sometime } if utilities.synccompleted{ completionhandler(uibackgroundfetchresult.newdata) }else { completionhandler(uibackgroundfetchresult.nodata) } } now have questions : as background fetch of 30 sec, if task not completed in 30 sec happens, because wont able set completionhandler .nodata or .failure is there default complet...

perl - Should Exception::Class objects evaluate to false in boolean context -

i'm trying exception::class first time , surprised me exception::class objects evaluate true when returned function. shouldn't default opposite. i know can change overload wondering if it's idea sub gethtml{ return myexception->new( error => 'some error' ); } $response = &gethtml if($response){ #do html } else{ #something went wrong check if it's exception object } you're confusing exceptions returning false value indicate error. part of point of exceptions provide own channel indicate error. leaves return free return valid values. there's no need check false vs defined, or special objects, or per-function call error checking @ all. it's caught , dealt @ end of block. if return exception object defeats point; they're not exceptions, they're error codes. to take advantage of exceptions, code in example should written this: sub get_html { ...try html... return $html if defined $html...

javascript - ngStorage not storing data when being updated -

i building directive handles out courses, part of saving course data in local storage user can resume. when data changes call function function setlocalstorage(){ if(!preview){ $localstorage.scorm = scope.scorm } } i call when first load course my problem data not updated in local storage. when debug can see $localstorage.scorm getting updated in chrome console data in actual local storage unchanged. solved using $apply function setlocalstorage(){ if(!preview){ scope.$apply(function () { $localstorage.scorm = scope.scorm; }); } }

java - Restful webservices with jersey and tomcat error: 404 -

i'm working eclipse creating dynamic web project. i'm using tomcat 7 , i've included jar jersey, here jars: aopalliance-repackaged-2.4.0-b31.jar asm-debug-all-5.0.4.jar hk2-api-2.4.0-b31.jar hk2-locator-2.4.0-b31.jar hk2-utils-2.4.0-b31.jar javassist-3.18.1-ga.jar javax.annotation-api-1.2.jar javax.inject-2.4.0-b31.jar javax.servlet-api-3.0.1.jar javax.ws.rs-api-2.0.1.jar jaxb-api-2.2.7.jar jersey-client.jar jersey-common.jar jersey-container-servlet-core.jar jersey-container-servlet.jar jersey-guava-2.21.jar jersey-media-jaxb.jar jersey-server.jar org.osgi.core-4.2.0.jar osgi-resource-locator-1.0.1.jar persistence-api-1.0.jar validation-api-1.1.0.final.jar my xml is: <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd...

sql - How to retrieve row values from a DataTable in c# -

i trying execute sql query in c# , store result in datatable variable. , want values particular row. here code. string query = "select * deptment dname=@dname"; con.open(); sqlcommand cmd = new sqlcommand(query, con); cmd.parameters.addwithvalue("@dname", combobox1.selectedtext); sqldatareader dr = cmd.executereader(); datatable dt = new datatable(); dt.load(dr); textbox2.text = dt.rows[0][0].tostring(); dept_name.text = dt.rows[0][1].tostring(); textbox1.text = dt.rows[0][2].tostring(); no_of_employees.text = dt.rows[0][3].tostring(); dept_discription.text = dt.rows[0][4].tostring(); con.close(); but getting error: there no row @ position 0. obviously no result. avoid exception add check if (dt.rows.count > 0) { textbox2.text = dt.rows[0][0].tostring(); dept_name.text = dt.rows[0][1].tostring(); textbox1.text = dt.rows[0][2].tostring(); no_of_employees.text = dt.rows[0][3].tostring(); dept_discription.text = dt.ro...

c++ - using int pointer in multiple couts -

i'm quite new world of pointers in c/c++ may quite easy question you: the following c++-code works normally #include <iostream> int main() { int theint = 1337; int & thereference = theint; int * thepointer = &theint; std::cout << "int: " << theint << "\n"; std::cout << "referenz: " << thereference << "\n"; std::cout << "pointer: " << *thepointer << "\n"; std::cout << "pointer: " << *thepointer << "\n"; //std::cout << "foo" << "\n"; return 0; } but stops working when changing //std::cout << "foo" << "\n"; to std::cout << "foo" << "\n"; . by "stops working" mean: "is blocked norton security potential threat" (resulting in return code of "0x76f...

c# - Save image of whole ListView -

i have next code: private static void snapshotpng(listview source, string destination, int zoom) { try { double actualheight = source.actualheight; double actualwidth = source.actualwidth; double renderheight = actualheight * zoom; double renderwidth = actualwidth * zoom; rendertargetbitmap rendertarget = new rendertargetbitmap((int)renderwidth, (int)renderheight, 96, 96, pixelformats.pbgra32); visualbrush sourcebrush = new visualbrush(source); drawingvisual drawingvisual = new drawingvisual(); drawingcontext drawingcontext = drawingvisual.renderopen(); using (drawingcontext) { drawingcontext.pushtransform(new scaletransform(zoom, zoom)); drawingcontext.drawrectangle(sourcebrush, null, new rect(new point(0, 0), new point(actualwidth, actualheight))); } rendertarget.render(drawingvisual); pngbitmapencoder encoder = new pngbitmapencoder(); ...

casting - Change data type varchar to timestamp along with null values in PostgreSQL -

change data type varchar timestamp along null values in postgresql have column empty rows , few timestamp rows. how convert timestamp data type in postgresql? you need using clause turn empty strings null . alter table ... alter column mycol type timestamp using (...conversion expression...) without seeing input data it's hard expression must be, involves nullif or case expressions , to_timestamp function and/or cast timestamp .

C++ dought completely Novice -

#include<iostream> using namespace std; class animal { private: string name; public: animal() { cout << "animal created" << endl; } animal(const animal& other): name(other.name){ cout << "animal created copying" << endl; } ~animal() { cout << "animal destroyed" << endl; } void setname(string name) { this->name = name; } void speak()const{ cout << "my name is: " << name << endl; } }; animal createanimal() { animal a; a.setname("bertia"); return a; } int main() { animal a_= createanimal(); a_.speak(); return 0; } i got output: animal created name is: bertia animal destroyed the "an...

MySQL python query for extracting data from columns -

i need construct query in mysql, output data. table named "data" , containig 3 columns "col1" in wich dates, not in sql format, "col2" contains times, , "col3" contains values need output. how construct query first check col1 specific date , check col2 specific time range between date in first column, , return values of selection. i have tried this: sql = "select * `data` `col 1`='6.9.2015' , time(`col 2`) between '23:00:00' , '23:59:00'" but query returns date of 7.9.2015. thank in advance answers. the problem using = compare strings. replace = like in order string comparisons. also, if want return col3 output, replace select * select 'col3' .

c++ - Adding blocking functions to lock-free queue -

i have lock-free multi producer, single consumer queue, based on circular buffer. far, has non-blocking push_back() , pop_front() calls. want add blocking versions of calls, want minimize impact has on performance of code uses non-blocking versions - namely, should not turn them " lock-by-default " calls. e.g. simplest version of blocking push_back() this: void push_back_blocking(const t& pkg) { if (!push_back(pkg)) { unique_lock<mutex> ul(mux); while (!push_back(pkg)) { cv_notfull.wait(ul); } } } but unfortunately require put following block @ end of "non-blocking" pop_front() : { std::lock_guard<mutex> lg(mux); cv_notfull.notify_all(); } while notify alone has hardly performance impact (if no thread waiting), lock has. so question is: how can (using standard c++14 if possible) add blocking push_back , pop_front member functions queue without severely impeding performance of n...

jquery - jstree : how to undelete / restore a node -

i using jstree in application contextmenu plugin. when deleting node, have ajax request performs operation on database. i'd delete node view if ajax returns operation = true parameter. how can undelete jstree node has been deleted following code : function (data) { var inst = $.jstree.reference(data.reference), obj = inst.get_node(data.reference); if(inst.is_selected(obj)) { inst.delete_node(inst.get_selected()); } else { inst.delete_node(obj); } } i delete node tree when call successful. doesn't make sense delete node first, make call , if fails try re-add node. here example delete node if ajax call success: var node = $('#tree').jstree('get_selected'); $.ajax({ url: link, type: 'get', data: { id: node.attr('id') }, async: false, success: function (data, text) { $('#tree').jstree('delete_node', node); }, error: function (reques...

javascript - Default selected value in a combobox -

i have combobox have in 2 types of laptops, toshiba , hp. on load selection default value nothing. want make default selected value toshiba, it's selected. such in html "selected". please? laptops = ext.create('ext.data.store', { fields: ['abbr','value', 'name'], data : [ {"abbr":"tosh","value":"toshibatypes", "name":"toshiba"}, {"abbr":"hp","value":"hptypes", "name":"hp"} ] }); toshibatypes = ext.create('ext.form.panel', { xtype: 'radiogroup', defaulttype: 'radio', layout: 'hbox', border:false, id: 'toshiba', width:'100%', items: [ { checked: true, boxlabel: 'toshiba 1', ...

android - Change language problems with recycleView -

i have problem (left bar) "android.support.v7.widget.recyclerview" when try change text, lateral not responding, think not load correctly. only exist activity, rest fragments, in activity have "left bar" @override public viewholder oncreateviewholder(viewgroup parent, int viewtype) { change text programatically @override public void onbindviewholder(viewholder holder, int position) { change text programatically i try change text, not work , think not called, because activity called first time i have control of fragment called "fragmentreutil2" have begintransaction. method put loadlanguage , .setadapter(again) note: (onresume) call 1 time (firsttime) my method call every times transition fragments. fragmentreutil2 all fragment works correctly without left bar i'm still not quite sure you're asking, think problem you're not calling 1 of following after you've changed data reflected on ui. ...

Oracle SQL group by week /month -

how can group reocrds weekly/monthly in oracle between date , date 1 record can returned 1 week/month. e.g if have 5 records ist weeek , 3 records second week between date , date should return total 2 records(one ist week , 1 second week). thanks in advance. you can group results using group by : http://www.techonthenet.com/oracle/group_by.php to select between date , date use where edit for selecting begining of week or month, can use trunc (the_date_field, ): http://www.techonthenet.com/oracle/functions/trunc_date.php for example groups week: select trunc(datecol_name, 'ww') table_name group trunc(datecol_name, 'ww');

c# - How to show IEnumerable hierarchy on cshtml? -

i have object list model on .cshtml page. @model ienumerable<someobject> each object have name, id , parentid. right showing data simple list: <ul> @foreach (var item in model) { <li> ... </li> } </ul> and looks like: --------- |test1 | //id=1 parentid=0 |test2 | //id=2 parentid=1 |test3 | //id=3 parentid=2 |test4 | //id=4 parentid=2 |test5 | //id=5 parentid=0 --------- but need show as: --------------- |test1 | //id=1 parentid=0 | test2 | //id=2 parentid=1 | test3 | //id=3 parentid=2 | test4 | //id=4 parentid=2 |test5 | //id=5 parentid=0 --------------- how can accomplish that? you need consider using recursive function. need change data structure in such way can used in recursive function. please see example have created public class menu { public int id { get; set; } public int parentid { get; set; } public string name { get; set; } public list<menu> chi...

html - CSS menu that scrolls aside content -

how can make menu scroll aside content. note content , menu inside container box(class=boxed) aligned center of page. above container there header 100% page width. .boxed{ width:100%; max-width: 1154px; margin: 0 auto; position: relative; } .boxed .sidebar{ position: relative; width: 25%; float: left; } the html this: <html> <body> <header>header content</header> <div class="boxed"> <nav id="sidebarmenu"> <ul id="sidebar"> <li></li> <li></li> </ul> </nav> <div class="content">content</div> </div> </body </html> html, body { height: 100%; margin: 0; font-size: 20px; } #left { width: 20%; height: 100%; position: fixed; outline: 1px solid; background: #...

Calculate difference between 2 date / times in Oracle SQL -

i have table follows: filename - varchar creation date - date format dd/mm/yyyy hh24:mi:ss oldest cdr date - date format dd/mm/yyyy hh24:mi:ss how can calcuate difference in hours minutes , seconds (and possibly days) between 2 dates in oracle sql? thanks you can substract dates in oracle. give difference in days. multiply 24 hours, , on. sql> select oldest - creation my_table; if date stored character data, have convert date type first. sql> select 24 * (to_date('2009-07-07 22:00', 'yyyy-mm-dd hh24:mi') - to_date('2009-07-07 19:30', 'yyyy-mm-dd hh24:mi')) diff_hours dual; diff_hours ---------- 2.5 note : this answer applies dates represented oracle data type date . oracle has data type timestamp , can represent date (with time). if subtract timestamp values, interval ; extract numeric values, use extract function.

.net - Outlook 2013 VSTO - Get calendar selected range + callback -

how can retrieve displayed date range in outlook calendar? example, when open week view of current week, need know in code current calendar displays range 2015-09-21 2015-09-27. let's assume have reference calendar mapifolder object. found out object has currentview member several promising properties. displayeddates contains no items, filter empty , selectedendtime / selectedstarttime both points 4501-01-01, i.e. no date set. doing wrong? , yes, @ time of evaluating object, calendar view in outlook open , active. second question: after possible current display range, there callback or event can consume fired when display range changes? try use currentview property of explorer class, not folder. obtain view object view of current explorer , use explorer.currentview instead of currentview property of current folder object returned explorer.currentfolder. here msdn states: the view object allows create customizable views allow better sort, group , view da...