sed -i '/##INSERT HERE/r file_to_insert.txt' file_inserted_to.txt
# now remove directive
sed -i 's/##INSERT HERE//g' file_inserted_to.txt
View ubuntu-server-setup.txt
Basic ubuntu home server set up
For shell login greeting
or change line “Banner” in /etc/ssh/sshd_config
This will display banner before authentication; may be best in bashrc
Enable SSH
read input;
git add .; git commit -m "$input"; git push;
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'));
} ))