Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'matrix'
require 'lingua/stemmer'
require 'csv'
require 'erb'
require 'iconv'
require 'sanitize'
require './cleaner.rb'
STEMMER = Lingua::Stemmer.new
@njm2112
njm2112 / uscode.rb
Created March 21, 2017 04:46 — forked from ashaw/uscode.rb
class USCode
SEARCH_ENDPOINT = "http://uscode.house.gov/uscode-cgi/fastweb.exe?search"
@@search_params = {
:view => "uscview",
:db2 => "t01t04" ,
:db3 => "t05t08" ,
:db4 => "t09t12" ,
:db5 => "t13t16" ,
:db6 => "t17t20" ,
:db7 => "t21t25" ,
@njm2112
njm2112 / mmoutline2md.rb
Created January 18, 2017 01:51 — forked from ttscoff/mmoutline2md.rb
Convert a Mindjet MindManager text outline export to Markdown
#!/usr/bin/env ruby
input = STDIN.read
input.gsub!(/^\=+\n ?(.*?)\n\=+/,"# \\1")
input.gsub!(/^-+\n\d+ (.*?)\n-+/,"## \\1")
input.gsub!(/^\d+\.\d+ (.*)/,"### \\1")
input.gsub!(/^\d+\.\d+\./,"@")
input.gsub!(/^@\d+ /,"- ")
input.gsub!(/^@\d+\.\d+ /,"\t- ")
@njm2112
njm2112 / StraightenQuotes.sh
Created December 24, 2016 17:18 — forked from benrothe/StraightenQuotes.sh
A TextExpander snippet to convert clipboard contents: “Curly” quotes to "straight", em-dashes to double-hyphens and ellipses to three periods.
#!/usr/bin/env php
<?php
$str = `pbpaste`;
$find = array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6");
$replace = array("'", "'", '"', '"', '-', '--', '...');
echo str_replace($find, $replace, $str);
@njm2112
njm2112 / SmartenQuotes.sh
Created December 24, 2016 17:17 — forked from benrothe/SmartenQuotes.sh
A TextExpander snippet to convert clipboard contents: "Straight" quotes to “curly”, double-hyphens to em-dashes and three periods to ellipses.
#!/usr/bin/env php
<?php
$str = `pbpaste`;
$str = preg_replace('/(^|[-\xe2\x80\x94\/(\[{"\s])\'/', "$1\xe2\x80\x98", $str);
$str = preg_replace('/\'/', "\xe2\x80\x99", $str);
$str = preg_replace('/(^|[-\xe2\x80\x94\/(\[{\xe2\x80\x98\s])"/', "$1\xe2\x80\x9c", $str);
$str = preg_replace('/"/', "\xe2\x80\x9d", $str);
$str = preg_replace('/--/', "\xe2\x80\x94", $str);
$str = preg_replace('/\.\.\./', "\xe2\x80\xa6", $str);
echo $str;

Cheatsheet

Move cursor

command description
ctrl+a Move cursor to the start of the line
ctrl+e Move cursor to the end of the line
ctrl+b Move cursor back one character
ctrl+f Move cursor forward one character
@njm2112
njm2112 / markdown.md
Created August 13, 2016 04:19 — forked from jonschlinkert/markdown-cheatsheet.md
A better markdown cheatsheet. I used Bootstrap's Base CSS documentation as a reference.

Typography

Headings

Headings from h1 through h6 are constructed with a # for each level:

# h1 Heading
## h2 Heading
### h3 Heading