read input;
while true; do clear; $input; sleep 2; clear; done;
cat \
file1 \
file3 \
> file3
View loop_over_json_array_with_nodejs.js
var fs = require('fs'),
util = require('util'),
exec = require('child_process').exec,
json = JSON.parse(fs.readFileSync('data.json'));
function puts(error, stdout, stderr){console.log(stdout, stderr)}
for (var i in json.array){
exec('echo '+json.array[i], puts);
View get_all_text_elements.js
// simple tag getting fn
var getTag = function(tag){
return document.getElementsByTagName(tag);
// wanted: elements we want to get by tag.
// caught: tags caught; where we will put the wanted elements, if they exist.
// missing: if tag not present in document, list here.
var textCatcher = {
wanted : ['p','ul','ol','li','a','span','strong','i','b','h1','h2','h3','h4','h5','h6'],
View format_multiline_exec.php
exec("$command 2>&1 &", $output);
foreach ($output as $line) {
echo "$line\n";
View jquery_keybinding.js
$(document).keyup(function(e) { //keydown can be used as well.
switch(e.which) {
case 37: //left; any keycode can be used for each case.
alert('keycode: '+e.which);
default: return; // exit this handler for other keys
e.preventDefault(); // prevent the default action (scroll / move caret)
View import_JSON_into_jade_gulpfile.js
var gulp = require('gulp'),
jade = require('gulp-jade'),
data = require('gulp-data'),
fs = require('fs');
gulp.task('jade', function(){
return gulp.src('src/jade/*.jade')
.pipe(data( function(file) {
return JSON.parse(fs.readFileSync('src/data.json'));
} ))
View readable_html_in_js.js
var newHTML = [
'<div class="foo">',
'<p>Readable HTML in JavaScript.</p>',
View get_any_element_on_click.js
// getting an event's target
function getElementByEvent(event){
// get the target
var element = document.getElementsByClassName('element')[0];
//adding event listener to target
element.addEventListener('click', function(event){