Skip to content

Instantly share code, notes, and snippets.

View epistrephein's full-sized avatar

Tommaso Barbato epistrephein

View GitHub Profile
@nakajima
nakajima / sinatra-auth.rb
Created October 13, 2008 01:12
Easy basic auth for Sinatra actions
=begin
Easy Basic Authentication for Sinatra actions.
USAGE
require 'rubygems'
require 'sinatra'
require 'sinatra-auth'
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@bulljit
bulljit / removecompletedtorrents.sh
Created January 22, 2011 23:17
Transmission-Daemon: Remove Completed Torrents
#!/bin/sh
# script to check for complete torrents in transmission folder, then stop and move them
# either hard-code the MOVEDIR variable here…
MOVEDIR=/home/mjdescy/media # the folder to move completed downloads to
# …or set MOVEDIR using the first command-line argument
# MOVEDIR=%1
# use transmission-remote to get torrent list from transmission-remote list
# use sed to delete first / last line of output, and remove leading spaces
# use cut to get first field from each line
@pksunkara
pksunkara / config
Last active April 20, 2024 04:50
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
@zeroasterisk
zeroasterisk / .zshrc
Created August 23, 2011 18:09
~/.zshrc for Oh My ZSH (alan)
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="alanpeabody"
#ZSH_THEME="dieter"
#ZSH_THEME="eastwood"
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created September 9, 2011 10:49
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@czj
czj / gist:1251031
Created September 29, 2011 15:43
.irbrc that runs Pry instead of IRB
# This script comes from Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
@3dd13
3dd13 / ruby_ftp_example.rb
Created November 5, 2011 17:08
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@Burgestrand
Burgestrand / README.md
Created February 3, 2012 23:20
A ruby script to construct magnet links out of .torrent files

Magneto

It reads your torrents. Spit out magnet URIs.

Example Usage

$ ./magneto.rb magneto.rb.torrent

Results in: