Skip to content

Instantly share code, notes, and snippets.

View upvalue's full-sized avatar
🐴

Phil upvalue

🐴
View GitHub Profile
@upvalue
upvalue / largest-files.py
Created August 2, 2012 17:55
get and sort the line count of each file (so you can find the largest ones)
#!/usr/bin/python
# usage: ./largest-files.py <file> ...
# for instance: ./largest-files.py *.c
# to find the largest c file in the current directory
import glob, sys, os, pprint
files = sys.argv[1:]
lines = []
for x in files:
@upvalue
upvalue / vimrc
Created November 10, 2012 08:13
Miniature version of vim rc for servers
filetype plugin indent on | syntax on | set ruler gd hls scs ic hid ts=2 sts=2 sw=2 tw=79 fo=cq nuw=5 wmnu wim=full cul cino=l1,(0 | map ; : | map i <Up> | map j <Left> | map k <Down> | noremap h i | set number
@upvalue
upvalue / buffer.lua
Created January 11, 2013 01:45
Simple circular buffers for Lua, which took me forever to get right for some reason.
-- Circular buffer functionality
local Buffer = {}
function Buffer:new(ob)
local o = ob or {}
o.entries = #o
o.cursor = #o + 1
o.max = 10
setmetatable(o, self)
self.__index = self
@upvalue
upvalue / likes.rb
Created May 15, 2013 21:25
Non-intrusive social sharing tags for Jekyll. Note: uses deprecated/private APIs, probably against TOS or whatever
# likes.rb - non intrusive sharing tags for jekyll/liquid
# usage (unfortunately rather verbose because of liquid)
# {{ site.url | append: page.url | facebook_likes }} => Fixnum
# {{ site.url | append: page.url | facebook_share_link }} => a link to share this page
# {{ site.url | append: page.url | twitter_tweets }} => Fixnum
# {{ site.url | append: page.url | twitter_share_link }} => Fixnum
# if you're doing it a lot, try something like this
# {% assign absolute = site.url | append: page.url %}
# NOTE: twitter ignores localhost urls. if you try to tweet one, the url will not appear in your tweet
@upvalue
upvalue / amazon.rb
Last active December 23, 2016 06:01
Amazon affiliate filters for jekyll.
# amazon.rb - amazon affiliate links for jekyll
# assumes that you have a configuration variable called 'amazon_associate_id' with your associate id
# usage: {{ asin | amazon_product_href }}
# returns url of a product
# usage: {{ asin | amazon_image_href: 'M' }}
# returns image of the product, size argument can be S, M, or L, default M
# usage: {{ asin | amazon_product: 'A Product' }}
@upvalue
upvalue / template.htm
Created May 25, 2013 04:47
html5 bootstrap skeleton with assets delivered by cloudflare
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
<![endif]-->
@upvalue
upvalue / .vimrc
Created August 5, 2014 02:55
Miniature vimrc for copying & pasting onto servers
filetype plugin indent on | syntax on | set ruler gd hls scs ic hid ts=2 sts=2 sw=2 tw=79 fo=cq nuw=5 wmnu wim=full cul cino=l1,(0 t_Co=256 | map ; :
@upvalue
upvalue / fix.sh
Last active March 14, 2017 20:16
Fix go get "you are not currently on a branch" error
#!/bin/bash
# https://groups.google.com/forum/#!topic/golang-nuts/t9dLLVwsMlM
# run in a directory of git repos e.g. ~/go/src/golang.org/x
for dir in ./*; do # use ./*/* for two-level directories eg ~/go/src/github.com
pushd $dir;
git pull --ff-only origin master;
popd;
done
@upvalue
upvalue / react-native-log.sh
Created March 15, 2017 01:00
less noisy react native logs
# removes all metadata from react-native log output
/opt/android-sdk/platform-tools/adb logcat -v raw "*:S" ReactNative:V ReactNativeJS:V
@upvalue
upvalue / webpack.config.js
Last active May 29, 2017 00:56
webpack + babel + react
// webpack.config.js - webpack 2 + babel + react + separate LESS to css file config
// Required packages:
// yarn add --dev webpack babel-loader babel-core babel-preset-es2015 babel-preset-react extract-text-webpack-plugin less css-loader style-loader less-loader
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './src/index.js',