Skip to content

Instantly share code, notes, and snippets.

View peterc's full-sized avatar
🏠
Working from home

Peter Cooper peterc

🏠
Working from home
View GitHub Profile
@imme5150
imme5150 / heroku_db_import.sh
Created November 5, 2014 10:27
Automatically capture, download and import a postgres DB from Heroku. You can supply an argument to the script to specify the app to use like this: `heroku_db_import.sh -amyapp` It reads the username and database name from config/database.yml
heroku pgbackups:capture $1 --expire
if [ "$?" == 0 ]
then
rake db:drop db:create
curl -o heroku_db_backup.dump `heroku pgbackups:url $1`
pg_restore --verbose --clean --no-acl --no-owner -h localhost `ruby -e "require 'yaml';db = YAML::load(File.read 'config/database.yml')['development']; puts ' -U ' + (db['username'] || 'postgres') + ' -d ' + db['database']"` heroku_db_backup.dump
rm heroku_db_backup.dump
fi
require 'rubygems'
require 'httparty'
require 'fileutils'
require 'json'
USERNAME = ARGV[0] || "patio11"
MAX_TO_FETCH = ARGV[1]
puts "Username: #{USERNAME} max to fetch: #{MAX_TO_FETCH || "all"}"
@cmod
cmod / twitter_notifications_only.css
Created September 16, 2014 14:38
Twitter Notifications
/*
Just the Notifications, please
==============================
1. Make a Fluid (http://fluidapp.com/) instance of https://twitter.com/i/notifications
2. Apply the below CSS as a Userstyles stylesheet
3. Enjoy just the conversation, not the timeline
Why?
@cmod
cmod / minimal_fb_messenger.css
Last active July 2, 2024 13:32
Minimal Facebook Messenger for Fluid
/*
Minimal Facebook Messenger
==========================
1. Make a Fluid (http://fluidapp.com/) instance of https://facebook.com/messages/
1. a. (You need to buy the paid version of Fluid to modify UserStyles)
2. Apply the below CSS as a Userstyles stylesheet
3. Like magic, you can now message without all the cruft of Full Facebook
@jashkenas
jashkenas / npm-publish-semver.coffee
Last active August 18, 2016 21:10
A little script to publish a "semantic" version of any npm package that uses real version numbers.
#!/usr/bin/env coffee
fs = require 'fs'
sh = require 'execSync'
config = JSON.parse fs.readFileSync 'package.json'
fs.renameSync 'package.json', 'package.json.real'
name = config.name = "#{config.name}-semver"
@kirillzubovsky
kirillzubovsky / How to delete all tweets with Ruby fast
Last active July 4, 2023 07:39
A quick way to delete all your tweets using Twitter archive and a ruby script.
require 'twitter'
require "json"
USERNAME = 'YOUR_TWITTER_USER_NAME'
ARCHIVE_PATH = 'archive/data/js/tweets'
client = Twitter::REST::Client.new do |config|
config.consumer_key = 'TWITTER_APP_API_KEY'
config.consumer_secret = 'TWITTER_APP_API_SECRET'
config.access_token = 'TWITTER_APP_ACCESS_TOKEN'
require 'spec_helper'
describe 'creating a person' do
it 'works with valid attributes' do
user = create(:user)
post "/api/people.json",
{ person: { name: 'Bob Johnson' } },
{ 'Authorization' => "Token token=#{user.authentication_token}" }
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 13, 2025 09:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@floehopper
floehopper / singleton_class_ancestors.rb
Last active January 4, 2016 14:59
Differences between ancestors of singleton class between Ruby v2.0 and v2.1
# ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
class X; end
X.ancestors # => [X, Object, Kernel, BasicObject]
X.singleton_class # => #<Class:X>
X.singleton_class.ancestors # => [Class, Module, Object, Kernel, BasicObject]
# ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
class X; end
X.ancestors # => [X, Object, Kernel, BasicObject]
X.singleton_class # => #<Class:X>
@juliangruber
juliangruber / README.md
Last active March 24, 2021 02:00
lightweight node-websocketd

node-websocketd

A lightweight node port of websocketd, originally written in go.

Usage

node-websocketd --port=8080 ./count.sh