Skip to content

Instantly share code, notes, and snippets.

View sts10's full-sized avatar

Sam Schlinkert sts10

View GitHub Profile
@sts10
sts10 / my_bash_prompt_functions
Last active August 29, 2015 13:56
My bash prompt functions (includes dirty git *)
# Add this parse_git_dirty function.
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
# Replace your parse_git_branch function with this one.
@sts10
sts10 / octo_new
Last active August 29, 2015 13:56
A bash function for creating a new Octopress post from anywhere in the terminal
function octo_new {
cwd=$(pwd) #save pwd as cwd
cd /Users/$USER/Documents/code/sts10.github.io
echo "Creating new octopress post called \""$1"\""
rake new_post["$1"]
cd source/_posts
FILENAME=`ls -t | head -1`
@sts10
sts10 / octo_new_v002
Last active August 29, 2015 13:56
A Bash function for easily creating new Octopress posts (version 0.0.2). Full repo here: https://github.com/sts10/octo_new
# Full github repo here: https://github.com/sts10/ink
function octo_new {
cwd=$(pwd) #save pwd as cwd
cd /Users/$USER/Documents/code/sts10.github.io
rake new_post["$1"]
echo "Creating new octopress post called \""$1"\""
@sts10
sts10 / octo_new_v003
Last active August 29, 2015 13:56
Adds a decent draft system (must create a drafts Git branch in order to use)
function octo_new {
cwd=$(pwd) #save pwd as cwd
cd /Users/$USER/Documents/code/sts10.github.io
if [[ $* == drafts ]]
then
git checkout drafts
ls source/_posts
echo ''
echo "Which file from your draft folder would you like to edit? Please enter the file's full name."
@sts10
sts10 / jot.sh
Last active September 23, 2015 02:22
Jot v 0.0.3 -- A note-taking script. Can be pasted into your .bash_profile
function jot {
MAP="/Users/samschlinkert/Documents/code/jot/path.txt"
JOT_ROUTE=$(<$MAP)
if [[ $1 == here ]]
then
NEW_PATH=$(pwd)
echo "$NEW_PATH/" > $MAP
echo "Now jotting in "$NEW_PATH
@sts10
sts10 / key_bindings
Last active August 29, 2015 14:00
My Sublime Text 2 key bindings
// Neccessary packages:
// Package Control, obviously https://sublime.wbond.net/
// Sass and CoffeeScript syntax highlighting https://sublime.wbond.net/packages/Sass
// https://sublime.wbond.net/packages/CoffeeScript
// Expand Selection to Quotes https://sublime.wbond.net/packages/Expand%20Selection%20to%20Quotes
// SublimeERB https://sublime.wbond.net/packages/SublimeERB
// (Could try ERB Autocomplete https://sublime.wbond.net/packages/ERB%20Autocomplete)
// One of the Markdown packages
[
{ "keys": ["alt+s"], "command": "toggle_side_bar" },
@sts10
sts10 / schlinkphoto_theme
Created December 5, 2014 17:53
My hacked-together Tumblr theme for schlinkphoto.tumblr.com, as of December 2014. Doesn't really support photosets. Install by copy and pasting as your theme code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{Title}</title>
<META NAME="Title" CONTENT="{Title}">
{block:Description}
<META NAME="Description" CONTENT="{MetaDescription}">
require 'twitter_ebooks'
# This is an example bot definition with event handlers commented out
# You can define and instantiate as many bots as you like
class MyBot < Ebooks::Bot
# Configuration here applies to all MyBots
attr_accessor :original, :model, :model_path
def configure
@sts10
sts10 / gist:2e52623b95b3e856d6e1
Last active August 29, 2015 14:23
Count number of Instagram posts in last 24 hours from a given user
require "sinatra"
require "instagram"
enable :sessions
CALLBACK_URL = "http://localhost:4567/oauth/callback"
Instagram.configure do |config|
config.client_id = "CLIENT_ID_THAT_YOU_HAVE_TO_GIVE_YOUR_PHONE_NUMBER_TO_GET_BUT_AFTER_THAT_IT_WAS_BASICALLY_INSTANT"
config.client_secret = "CLIENT_SECRET"
@sts10
sts10 / amazon_prime_day.rb
Last active August 29, 2015 14:25
Makes array of dates where (day + month + last_two_digits_of_year) and number of days since Jan 1, 1970 have both been prime since Jan 1, 1970
# Makes array of dates where (day + month + last_two_digits_of_year) and number of days since Jan 1, 1970 have both been prime since Jan 1, 1970
require 'prime'
require 'date'
def date_to_sum(date)
date.month + date.day + date.year.to_s[2..-1].to_i
end
date_to_go_up_to = Date.parse("2017-01-01")