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
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@th0ma5w
th0ma5w / horoscopescrape.py
Created January 12, 2011 14:38
Example of Generating URLs for downloading
"""
Creates a list of URLs to stdout based on repeating patterns found in the site, suitable for use with WGET or CURL.
"""
import datetime
scopes=[
"aries",
"taurus",
@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
@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
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',
@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
@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
@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):
@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
@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).