Skip to content

Instantly share code, notes, and snippets.

View isakb's full-sized avatar
💭
I may be slow to respond.

Isak Bakken isakb

💭
I may be slow to respond.
View GitHub Profile
@isakb
isakb / word-spider.rb
Created March 17, 2012 14:15
A spider I wrote many years ago. Put here for archaeological purposes. Crawls web pages and creates word histograms to figure out most common words.
#! /usr/bin/env ruby
['rubygems', 'spider', 'hpricot', 'iconv'].each {|f| require f }
class Converter
def initialize(encoding_to="utf8")
@to = encoding_to
end
def convert(str, encoding_from)
i = Iconv.new(@to, encoding_from)
c_str = ""
begin
@isakb
isakb / .gitignore
Created March 23, 2012 19:50 — forked from jondot/app.coffee
Backbone Image Gallery 2.0
app.js
@isakb
isakb / install_node_and_npm.sh
Created August 29, 2012 17:32
Dependency checker and installer for node.js and npm
#!/bin/bash -e
#
# This script checks if useful versions of node.js and npm are installed
# on the system, and if not it attempts to install them.
#
# Should work on Debian based systems and OS X.
# So far tested on Kubuntu 12.04.
#
_die(){
@isakb
isakb / package.json
Created September 21, 2012 22:58
Escodegen with comments etc.
Whatever.
@isakb
isakb / bookmarklet
Created February 8, 2013 01:16
Instant HTML editor anywhere (with markup exporting function)
# Exploratory variant of: http://www.quora.com/Web-Development/What-are-the-most-interesting-HTML-JS-DOM-CSS-hacks-that-most-web-developers-dont-know-about/answer/Mohnish-Thallavajhula?__snids__=92752551&__nsrc__=1
# Enter the following URI in a browser and/or save it as a bookmarklet:
data:text/html,<body contenteditable id=$><p>w<b>rite</b><i> rich</i> text..</p><button style="top:0;right:0;position:fixed"onclick=alert($.innerHTML.slice(0,-112))>Get HTML Markup
# Congratulations, you now have a *very* hackish rich text format editor with a button to get the text as HTML, anytime you click the bookmarklet.
@isakb
isakb / watchish
Created February 15, 2013 17:02
Simple watch variant
#!/bin/bash
# A variant of watch, with smarter color support etc.
[[ $SLEEP ]] || SLEEP=2
cmd=$*
prev_output=""
while true ; do
output="$( $cmd 3>&1 2>&3 )"
@isakb
isakb / gist:6580890
Created September 16, 2013 13:46
Convert a whole JS project to CoffeeScript (first step)
for f in `find . -name '*.js'`; do js2coffee $f > ${f%%js}coffee && rm $f; done
@isakb
isakb / doge_js_console.html
Created February 13, 2014 23:48
Console override, doge_js style. For Chrome and Firebug.
<script>
(function(){
console.log('%c very console',
'color: blue; font-size: 24px; font-family: "Comic Sans MS"');
console.log('%c such script',
'color: green; font-size: 18px; font-family: "Comic Sans MS"');
Object.defineProperty(console, '_commandLineAPI', {
@isakb
isakb / install_ni_prefix.sh
Last active July 2, 2018 12:52
Create "ni" prefix to disable internet access for specific commands
#!/bin/bash
# Install "ni" prefix for executing scripts without allowing internet access.
# Tested on Ubuntu 13.04.
# Example:
# $ ni ping google.com
# ping: unknown host google.com
#
# $ ping google.com
# PING google.com (173.194.40.229) 56(84) bytes of data.
# 64 bytes from arn02s06-in-f5.1e100.net (173.194.40.229): icmp_req=1 ttl=59 time=1.41 ms
@isakb
isakb / instructions
Created March 1, 2014 01:17
google translate is a beatbox
1. Open http://translate.google.com/#ja/en/gh%20bchtk%20pv%20zk%20pv%20pv%20zk%20pv%20zk%20kz%20kh%20pv%20zk%20pv%20zk%20bchkt%20zk%20pzk%20pzk%20kkkkkk%20bsch%0Abchtk%20zk%20kppp%20bsch%20sss%20gh.
2. Press the left speaker button to listen.
3. Record output with:
parec --format=s16le --device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | oggenc --raw --quiet -o dump.ogg -