Posts

In bash, how can cmd1 | cmd2 return cmd1's status code, when cmd1 fails? -

simple example: user:/$ find /garbage | wc -l find: '/garbage': no such file or directory 0 user:/$ echo $? 0 find fails, wc executes , $?=0 . rather abort, , $? set find 's status code. this seems work user:/$ find /garbage 2> /dev/null && if [ ! $? -eq 0 ]; exit $?; fi | wc -l user:/$ echo ? 3 but it's clunky , feels there's cleaner, more bashonic solution. taken man bash : the return status of pipeline exit status of last command, unless pipefail option enabled. if pipefail enabled, pipeline's return status value of last (right‐ most) command exit non-zero status, or 0 if commands exit successfully. if reserved word ! precedes pipeline, exit status of pipeline logical negation of exit status described above. shell waits commands in pipeline terminate before returning value. to set it: set -o pipefail

JQuery to Parse XML file in Electron -

i have following xml file: test.xml <page> <checkbox> <label>works</label> </checkbox> </page> i have electron set , have jquery implemented correctly. when say: var xml = "<page><checkbox><label>works</label></checkbox></page>"; var doc = $.parsexml(xml); var $xml = $(doc); var $checkbox = $xml.find("checkbox"); $checkbox.each(function(){ var label = $(this).find('label').text(); $(".ntbk-container" ).append('<input type=checkbox class=checkbox>'+label+"</input>"); }); the page renders correctly , checkbox. want read file, did i've seen many people do: var file $.get(file_path,function(data){ file = data; },'text') var xml = file; ...(the rest of prevoious code) then no result. how able this?

c - Return argument doesn't work — gives me weird error -

this simple program should create substring string, should return substring can printed out. it's exercise , substring function can changed. problem can't find return type doesn't spark kinds of warnings , errors. how should change return type? static void panic(const char *serror) { printf("%s", serror); exit(1); } static void *xmalloc(size_t size) { void *ptr; if (size == 0) panic("size 0!\n"); ptr = malloc(size); if (!ptr) panic("no mem left!\n"); return ptr; } static char *substring(const char *str, off_t pos, size_t len) { char out [len]; int index; for(index = 0; index < (pos + len); index++) { if(index >= pos && index < (pos + len)) { out[index - pos] = str[index]; } } return out; } int main(int argc, char **argv) { char *foo = "nicht\n"; char *bar = substring(foo, 2, 3); printf("%s...

javascript - How do I properly show/hide elements after an AJAX call using jQuery? -

what i'm using requires 2 clicks each action: first click: logs nothing, nothing second: logs doesn't exist , element displays third: (2) exists , element doesn't toggle fourth: (5) exists , element toggles fifth: (9) exists , element doesn't toggle sixth: (14) exists , element toggles what's causing weird behavior? # views/articles/description.js.erb $(function() { return $("#link-<%= @article.id %>").on("click", function(e, data, status, xhr) { e.preventdefault(); var description = '<p class="article__description"><%= j @article.description %></p>'; if ($("#article-<%= @article.id %> .article__description").length) { console.log("exists"); $("#article-<%= @article.id %> .article__description").toggle(); } else { console.log("doesn't exist"); $("#article-<%= @ar...

connecting django app with python script in my LAN -

i have local script collects info tasks of printers in lan, , have django app holds general info work. thing want know how put info generated local script in django database hosted in pythonanywhere?. i use python 2.7 , django 1.8.4 registration-redux package. any useful? thanks

html - why does bootstrap carousel take margin on its left and right side automatically? -

Image
i trying make carousel full screen. means need carousel 100% wide literally. leaving place on left , right side. other elements working fine. here image: my code is: <div class="container-fluid"> <div id="mycarousel" class="carousel slide" data-ride="carousel"> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="images/slide-1.jpg" alt="" /> </div> <div class="item"> <img src="images/slide-2.jpg" alt="" /> </div> <div class="item"> <img src="images/slide-3.jpg" alt="" /> </div> </div> </div> <div style="width: 100%; height: 300px; background: #990000;">&nbs...

Why does Twitter Bootstrap 3.1.0 wastes horizontal space on wide screens? -

twitter bootstrap 3.1.0 comes rules waste horizontal space on wide screens. when remove them nothing seems break, breaking. know if break or why these included? thank you! @media (min-width: 768px) { .container { width: 750px; } } @media (min-width: 992px) { .container { width: 970px; } } @media (min-width: 1200px) { .container { width: 1170px; } } from why bootstrap 3 force container width sizes? , the official answer bootstrap folks: what boils down designing specific breakpoints easier (in mind) designing unlimited, unknown sizes. alternative mention isn't wrong or bad, different. i'd rather maintain tiers specific ranges bootstrap's grid system makes more feasible method. there shouldn't breaking if find other spacing issues continue digging, might reason.