Skip to content

Instantly share code, notes, and snippets.

@kimmel
kimmel / gist:2922922
Created June 13, 2012 08:58
basic html5 page
<!DOCTYPE html>
<html lang="en-us" class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="screen" />
@kimmel
kimmel / gist:2928122
Created June 14, 2012 05:18
duckduckgo url scheme
duckduckgo url settings:
kp - safe search -1 == off
kl - set region us-en == USA
kc - auto load more results -1 == off
kf - favicons -1 == off
kb - embeds n == none
kv - page numbers 1 == on
k4 - sidebar -1 == off
@kimmel
kimmel / gist:3065174
Created July 7, 2012 06:54
dir processing script
#!/usr/bin/perl
use utf8;
use v5.10;
use warnings;
use File::Spec;
if ( $#ARGV == -1 ) {
say 'Usage: fix_dirs.pl [FILE]';
exit;
@kimmel
kimmel / gist:3401826
Created August 20, 2012 07:23
.bashrc history tracking
mkdir -p ~/.history
shopt -s histappend
shopt -s cmdhist
export HISTFILE=~/.history/`date +%Y-%m-%d`.hist
PROMPT_COMMAND="history -n;history -a"
@kimmel
kimmel / clean_history.pl
Created August 20, 2012 09:59
Clean unneeded entries from shell history files
#!/usr/bin/perl
use 5.014;
use warnings;
use autodie;
use utf8::all;
use IO::All;
die 'No input file specified.' if ( $#ARGV == -1 );
@kimmel
kimmel / gist:3402778
Created August 20, 2012 10:02
clean_history.pl without the patterns
#!/usr/bin/perl
use 5.014;
use warnings;
use autodie;
use utf8::all;
use IO::All;
die 'No input file specified.' if ( $#ARGV == -1 );
@kimmel
kimmel / gist:3415273
Created August 21, 2012 13:08
nytprof generates error messages with this code
#!/usr/bin/perl
use v5.14;
use warnings;
use utf8::all;
use autodie;
open my $source, '<', 'dracula.txt';
foreach my $line (<$source>) {
@kimmel
kimmel / gist:3415297
Created August 21, 2012 13:13
works fine with nytprof
#!/usr/bin/perl
use v5.14;
use warnings;
use autodie;
use utf8::all;
open my $source, '<', 'dracula.txt';
foreach my $line (<$source>) {
@kimmel
kimmel / gist:3482179
Created August 26, 2012 18:05
ruby regexp html parsing 1
next if content =~ />#{username}</ # skip if we posted it
next unless post.inner_html =~ /vote/ # skip if it's not a post
id = content[/\_(\d+)/,1]
comment_text = (post/'.comment').first.inner_text
commenter = content[/user\?id=(\w+)/,1]
@kimmel
kimmel / gist:3482190
Created August 26, 2012 18:06
ruby regexp html parsing 2
# The following regexp will break
indentation = '<img src="http:\/\/ycombinator.com\/images\/s.gif" height=1 width=(\d+)><\/td>'
score = '<span id=score_([0-9]+)>([0-9]+) point'
user_id = '<a href="user\\?id=([^"]+)">'
time_ago = '<\/a>([^\|]+)\|'
comment_body = '<span class=\\"comment\\"><font color=#000000>(.*?)<\\/font>'
regexp_str = "#{indentation}.*?#{score}.*?#{user_id}.*?#{time_ago}.*?#{comment_body}"