Skip to content

Instantly share code, notes, and snippets.

View parkr's full-sized avatar
📡
E.T. Phone Home

Parker Moore parkr

📡
E.T. Phone Home
View GitHub Profile
@imathis
imathis / Guardfile
Last active December 19, 2015 11:19
Guard-Jekyll-Plus is a fancy Guard script for managing "smart" Jekyll builds. Changes in the source directory to non-template files will trigger a simple filesystem copy (or delete) to the destination directory. Changes to template files (configured by file extension) will trigger a Jekyll build.
require 'guards/guard-jekyll-plus.rb'
# Sample guard
guard :jekyll do
watch /^source/
watch '_config.yml'
end
@voidfiles
voidfiles / expandurl.py
Last active December 12, 2015 09:29
I wanted to share clean URL's directly from my phone. This is most specifically geared towards feedburner URL's, but could be just short URL's as well. This script unwraps any URL's surrounded with ** in the text on your clipboard. Unwraps them, and clears out unwanted query params. Then opens the text in felix for posting.
"""
Pythonist script to expand any URL surrounded by **'s
"""
import clipboard
import requests
import webbrowser
import urlparse
from urllib import quote, urlencode
@cobyism
cobyism / gh-pages-deploy.md
Last active May 3, 2024 19:07
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@webchi
webchi / environment.rb
Created March 19, 2012 00:56
Custom form error messages for rails and yaml.de css framework
# This this replacemnt for default rails field_with_errors for using http://www.yaml.de/docs/index.html#yaml-forms
# Add this to ./config/environment.rb file
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<label/
%|<div class="ym-error"><p class="ym-message">#{[instance.error_message].join(', ')}</p>#{html_tag}</div>|.html_safe
else
%|<div class="ym-error">#{html_tag}</div>|.html_safe
end
@parkr
parkr / line_count.py
Created September 20, 2011 01:34
Python Line Count
#! /usr/bin/env python
# By Parker Moore, http://www.parkermoore.de/
# Referenced the following URLs and compiled:
# http://lookherefirst.wordpress.com/2007/12/03/check-if-an-entry-is-a-file-or-directory-in-python/
# http://stackoverflow.com/questions/845058/how-to-get-line-count-cheaply-in-python
import sys, os
def file_len(fname):
@fundon
fundon / vim_centos.sh
Created August 17, 2011 03:52
install vim 7.3 on centos, debian, arch etc.
#!/bin/bash
# on centos minimal
yum install gcc
yum install make
yum install ncurses-devel
yum install lua lua-devel
yum install ruby ruby-devel
yum install python python-devel
yum install perl perl-devel
@benedikt
benedikt / rails.rb
Created July 30, 2011 13:16
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
end
end
require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
module Strategies
class Instapaper < OmniAuth::Strategies::XAuth
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
client_options = {
:title => 'Instapaper',
@sdb
sdb / ril2ip.py
Created March 11, 2011 23:09
copy bookmarks from Read It Later to Instapaper
#! /usr/bin/env python
"""
Script to copy all bookmarks from Read It Later to Instapaper.
See also http://readitlaterlist.com/api/docs/#get
and http://www.instapaper.com/api/simple
"""
import urllib, urllib2, json
@th0ma5w
th0ma5w / extract_horoscope.py
Created January 12, 2011 14:41
extract context from downloaded html files
"""
Example of using the old BeautifulSoup API to extract content from downloaded html files into CSV... if you're doing this sort of thing today, I recommend using the newer lxml interface directly, but lxml also has a BeautifulSoup compatibility layer.
"""
import os