Posts

shell - Is trap EXIT required to execute in case of SIGINT or SIGTERM received? -

i have simple script trap 'echo exit' exit while true; sleep 1; done and behaves differently in different shells: $ bash tst.sh ^cexit $ dash tst.sh ^c $ zsh tst.sh ^c $ sh tst.sh ^cexit so i'm not sure how should operate , whether specified @ all. the exit trap isn't working same way in every shell. few examples: in dash , zsh it's triggered regular exit within script. in zsh, if trap signal quit execution, need restore default behaviour explicitly calling exit . i'd suggest catch signals , exit, should portable across shells: $ cat trap trap 'echo exit; exit' int term # , other signals while true; sleep 1; done $ bash trap ^cexit $ dash trap ^cexit $ zsh trap ^cexit $ ksh trap ^cexit $ mksh trap ^cexit $ busybox sh trap ^cexit

c# - Use Linq to iterate over ConfigurationManager.ConnectionStrings? -

is possible this? var strings = configurationmanager.connectionstrings; var names = (from d in strings select new connectionname(d.name)); yes, because connectionstrings not implement typed ienumerable , have tell linq type collection contains. use either from connectionstringsettings d in strings or configurationmanager.connectionstrings.cast<connectionstringsettings>() .

javascript - How to get Chosen and FastClick to work on mobile device -

i'm trying add fastclick site uses chosen jquery plugin selects. fastclick, selection boxes stop responding taps on mobile browsers. can replicated chrome device emulation. you can test on simple jsfiddle : <select id="foo"> <option>bar</option> <option>asdf</option> </select> $("#foo").chosen() steps replicate chome canary: load http://fiddle.jshell.net/7ftdo0j3/3/show/ open developer tools , emulate google nexus 7 or apple ipad 1/2 (others might work well) try use select. the main problem have try use 2 libraries together, both either manipulate or interpret touch event weirdly. wanted use phrase "which both black magic touch events", have none experience in using libraries in question, felt perhaps it's not appropriate ;) joking aside, solution problem add fastclick's needsclick class dom elements dynamically created chosen: $("#test").chosen(); $("....

How can I run this JavaScript snippet only once when a user logs in? -

i have simple javascript snippet. <script> window.onload = function(){ swal("hello!", "welcome portal", "success"); }; </script> how can run if page url http://portal/?init i.e. not run when page url http://portal or http://portal/?something_else ? check location.search of page. <script type="text/javascript"> if(location.search == "?init"){ window.onload = function(){ swal("hello!", "welcome portal", "success"); }; } </script>

angularjs - Form not adding to array and clearing -

in controller, have simple array , function: $scope.newguarantor = ''; $scope.guarantors = [ {guarantor: 'peter parker'}, {guarantor: 'bruce wayne'} ]; $scope.addguarantor = function(){ $scope.guarantors.push({ guarantor: $scope.newguarantor }); $scope.newguarantor = ''; }; in view have simple list , form: <tr ng-repeat="pg in guarantors"> <td>{{pg.guarantor}}</td> </tr> <tr> <td> <form ng-submit="addguarantor()"> <input type="text" ng-model="newguarantor"/> <button type="submit"> <span class="glyphicon glyphicon-plus"></span> </button> </form> </td> </tr> according read, should able type value input , click button , value of input should added listed array , form cleared. instead, getting empt...

jquery animation scrollTop dont work in ie or firefox -

a simple scroll top effect...the code doesn't work in ie or firefox works fine in chrome. html this : <a href="#" class="scrolltop"><i class="glyphicon glyphicon-chevron-up"></i></a> and script this : $(document.body).animate({ 'scrolltop':'0' },2000); i have tried replace $(document.body) $("body") ,nothing happen... i posted similar answer on post: jquery add ids paras make them linkable. i tested following code on firefox , ie 10 , works fine. $('html, body').animate({ scrolltop : 0 }, 500);

excel - AutoHotkey's ComObjActive handle to specific Worksheet -

the simplest way create handle active excel sheets in .ahk script is: xl := comobjactive("excel.application") nonetheless, if 1 switches workbook, becomes new " currently active sheet " , autohotkey tries use methods sheets , cells on new workbook through com: of course scripts designed work specific sheets , cells don't work anymore on different workbook. do know how create com handles specific workbooks instead of active sheet? the goal should allow user loop between workbooks without xl object losing previous handle , going new one. example open excel workbook scratch , type 1234 in cell a1 of sheet named " sheet1 "; create new .ahk script following content: #persistent xl := comobjactive("excel.application") settimer, xlread, 5000 return xlread: { value := xl.sheets("sheets1").range("a1").value msgbox, %value% } return script above should display "1234" in message box every 5 secon...