Skip to content

Instantly share code, notes, and snippets.

View rsvp's full-sized avatar
🎧
say hi ! https://gitter.im/rsvp/pub

Adriano rsvp

🎧
say hi ! https://gitter.im/rsvp/pub
View GitHub Profile
@rsvp
rsvp / uniqnosort
Created January 17, 2011 03:13
uniqnosort : uniq replacement -- shell script to get unique lines WITHOUT prior sort -- preserves original ordering where any subsequent duplicates are removed. Duplicates do NOT have to be adjacent to each other!
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-01-16
#
# _______________| uniqnosort : get unique lines WITHOUT sorting.
#
# Usage: uniqnosort [file, or use as pipe]
#
# NB: More famous "uniq" requires duplicates on adjacent lines.
# If you really want to sort and get uniques,
# try "sort -u" rather than "sort | uniq".
@rsvp
rsvp / flippar.sh
Created December 10, 2011 04:17
flippar.sh : reverse the order of paragraph blocks where such blocks are delimited by two or more newlines.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-12-10
#
# _______________| flippar : reverse order of paragraph blocks
# (delimited by two or more newlines;
# last block is exempt from this rule).
#
# Usage: flippar [filename (pipe acceptable)]
#
# Dependencies: tac (from package 'coreutils' in main)
@rsvp
rsvp / prepend.sh
Created December 14, 2011 16:12
prepend.sh : insert text above given line number (the first by default) or pattern. Bash script.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-12-14
#
# _______________| prepend : insert text above given line number or pattern.
#
# Usage: prepend ["text"] [filename=stdin] [linenum=1 OR pattern]
#
# Example: prepend "TEST1\nTEST2" foo 3
# # insert two test lines above the third line in file foo.
# sort foo | prepend "Sorted result:"
@rsvp
rsvp / lstest.sh
Created February 8, 2012 03:41
lstest.sh : list files by type (regular, directory, symbolic link, named pipe, etc.), and optionally show detailed information unavailable via the ls command (while also properly handling dot files). Linux bash script.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2012-02-04
#
# _______________| lstest : list files by type, optionally show further info.
#
# Usage: lstest [test flag] [-0|-1|-A|-i|-I|-a] [--count]
#
# ^attributes
# ^terse "stat"
# ^info via "stat"
@rsvp
rsvp / soundcloud-mp3.js
Created March 9, 2012 02:54 — forked from pheuter/sc-dl.js
SoundCloud bookmarklet that generates link to download MP3
/**
2012-03-26 Forked from duncanbeevers' sc-dl.js : https://gist.github.com/2157987
**/
(function(document) {
var link = document.createElement("a"),
span = document.createElement("span"),
slug = document.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1],
mp3 = document.querySelector("em").innerText + ".mp3";
@rsvp
rsvp / argin.sh
Created March 25, 2012 03:14
argin.sh : universal xargs properly handled from ANY standard input. Plus parallelization is activated by default. (No more hassles with the null character :-) argin.sh converts lines from stdin into arguments to build and execute a command individually.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2012-03-22
#
# _______________| argin : xargs properly handled from ANY standard input.
# xargs converts stdin into arguments in order
# to build and execute a command individually.
#
# Usage: argin [options] command [{} as placeholder if necessary]
#
# Examples: % argin -t echo {} < foo.txt 2> argin-done.txt
@rsvp
rsvp / colline.sh
Created March 25, 2012 02:45
colline.sh : convert column to line with optional delimiter string.
#!/usr/bin/env bash
# bash 3.2.25(1) Ubuntu 7.10 Date : 2012-03-25
#
# _______________| colline : convert column to line with optional delimiter.
#
# Usage: colline [file] [delimiter]
# ^space as default; string is acceptable.
# ^assuming each line represents one column.
#
# Dependencies: awk, sed
@rsvp
rsvp / quotel.sh
Created March 25, 2012 02:58
quotel.sh : quote lines using prefix and suffix strings. By default, those are double quotes.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2012-03-23
#
# _______________| quotel : quote lines using prefix and suffix strings.
#
# Usage: quotel [filename] [prefix string] [suffix string]
# # stdin and double quotes are defaults.
# # Use '~' to represent an empty string.
#
# Dependencies: sed
@rsvp
rsvp / linecol.sh
Created April 1, 2012 23:49
lincol.sh : convert regex delimited lines into single column. E.g. linecol foo.csv ', *' #-- so each item on a CSV line will be on its own line.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2012-04-06
#
# _______________| linecol : convert regex delimited lines into single column.
#
# Usage: linecol [filename] [delimiter regex]
#
# Examples: % linecol foo.csv ', *'
# # ^use single quotes for regex.
# # Each item on a CSV line will be on its own line.
@rsvp
rsvp / sto.sh
Created April 23, 2012 00:28
sto.sh : interim temporary storage with tee, pager, format, diff. Fast quintessential command-line management between three storage units. Linux bash script.
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2012-04-10
#
# _______________| sto : interim tmp storage with tee, pager, format, diff.
# There are THREE storage units.
#
# Usage: sto [ input: i, j, k output: oi, oj, ok diff: d??
# append: I, J, K xclip: x, y, z shift: s
# format: f, g, h addclip: X, Y, Z accumulate: a
# copy: ci, cj, ck [new prefix] cat: c