Skip to content

Instantly share code, notes, and snippets.

View philipmat's full-sized avatar

Philip Mateescu philipmat

View GitHub Profile
@philipmat
philipmat / index.html
Created February 25, 2014 16:42
Nav and left columns then full width.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<style type="text/css">
.page-container { width: 90%; margin: 10px auto; border: 1px solid gray; }
.menu { float: left; width: 160px; margin: 0; padding: 10px; border: 1px solid red; }
.small { margin-left: 200px; border: 1px solid green; }
.wide { margin-left: 0px; width: 100%; border: 1px solid blue; clear: both;}
</style>
@philipmat
philipmat / .gvimrc
Created February 28, 2014 15:43
vimrc
set numberwidth=5
" Supplement to .vimrc
let s:running_windows = has("win16") || has("win32") || has("win64")
if has("gui_macvim")
" Enable shortcuts using the Alt/Option/Meta key on the Mac
set macmeta
endif
" gVim does well in paste mode
@philipmat
philipmat / Regex-CSV.cs
Created February 28, 2014 15:48
Regex for CSV
var d = @"Col1,Col2,Col3,Col4
Foo,100,""Foo,Bar"",""Foo
Bar
Baz""
Bar,101,,Quux";
var rx = new Regex("((?<=^|,)(?<field>)(?=,|$)|(?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")*)\")(,|(?<rowbreak>\\r\\n|\\n|$))", RegexOptions.Multiline);
var matches = rx.Matches(d);
matches[6].Groups["field"].Dump();
matches.Dump();
@philipmat
philipmat / dcat.sh
Created June 15, 2014 14:42
dcat = ls + cat - treat files and directories uniformly
# alias d="dcat"
# d ~/Documents/
# d .gitignore
#
function dcat() {
local path=${1:-.}
if [[ -d "$path" ]] ; then
ls -al "$path"
elif [[ -f "$path" ]] ; then
@philipmat
philipmat / recover.ps1
Created August 14, 2014 17:11
Output the content of all git objects changed between two dates (useful for when the repo gets borked)
# Usage: (execute in the .git/objects folder)
# recover.ps1 -startDate "8/13/2014 1:22:00pm" -endDate "8/13/2014 8:00:00pm" > borked_files.txt
[CmdletBinding()]
Param(
[string]$startDate,
[string]$endDate
)
$start = [datetime]::Today
if ($startDate) {
@philipmat
philipmat / index.html
Last active August 29, 2015 14:05
Anagram solver for DrawSomething
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Drawanagram</title>
<!-- iPhone -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-touch-fullscreen" content="yes" />
<!-- /iPhone -->
@philipmat
philipmat / cleanup_total.py
Created August 3, 2015 04:33
Brew Cleanup Calculator
from __future__ import print_function
import re
import sys
# 1. brew cleanup > /tmp/brew_cleanup.txt
# 2. python cleanup_total.py /tmp/brew_cleanup.txt
cleanup_file = '/tmp/brew_cleanup.txt'
if len(sys.argv) > 1:
file = sys.argv[1]
@philipmat
philipmat / gist:1196552
Created September 6, 2011 04:05
Books24x7 page cleanup
d = document;
function p(n){return n.parentNode}
function $(x){return d.getElementById(x)}
function $t(x){return d.getElementsByTagName(x)}
function $c(x){return d.getElementsByClassName(x)}
function $r(n){p(n).removeChild(n)}
if (d.location.href.indexOf('mobile.books24x7') != -1 ) {
while($t('link').length != 1) {
l = $t('link');
for(var i = 0; i < l.length; i++) if (l[i].href.indexOf('grison') == -1) $r(l[i]);
@philipmat
philipmat / gist:1202891
Created September 8, 2011 08:08
npm update -g
# npm update -g -ddd
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'update',
npm verb cli '-g',
npm verb cli '-ddd' ]
npm info using npm@1.0.27
npm info using node@v0.5.5
npm verb /usr/local/bin/node node symlink
@philipmat
philipmat / transmission_cli.sh
Created September 14, 2011 03:57
transmission cli for freenas
#!/bin/bash
# filename: transmission_cli_manager.sh
# author: Dan Merschi
# date: 2009-01-17 (0.69 rev.4260)
# update: 2009-03-01 (0.69 rev 4403)
# purpose: A fast and easy solution(script) to manage Transmission daemon via transmission-remote client
# source: http://sourceforge.net/apps/phpbb/freenas/viewtopic.php?f=12&t=822
#
if [ -z "$(pgrep transmission-daemon)" ] ;then echo Transmission not running, abort.; exit 3; fi
eval $( ps axww | \