Skip to content

Instantly share code, notes, and snippets.

View TimFletcher's full-sized avatar

Tim Fletcher TimFletcher

View GitHub Profile
@brenogazzola
brenogazzola / direct_upload.js
Created January 20, 2022 23:41
Active Storage Direct Upload Progress
import Rails from '@rails/ujs'
const DirectUpload = {
start () {
document.addEventListener('direct-upload:initialize', DirectUpload.initialize)
document.addEventListener('direct-upload:start', DirectUpload.begin)
document.addEventListener('direct-upload:progress', DirectUpload.progress)
document.addEventListener('direct-upload-error', DirectUpload.error)
document.addEventListener('direct-upload:end', DirectUpload.end)
},
@fieg
fieg / redis-expire.sh
Last active October 10, 2022 23:09
Set expire on large set of keys using pattern in Redis
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Usage: $0 <host> <port> <pattern> <seconds>"
exit 1
fi
cursor=-1
keys=""
@panthomakos
panthomakos / benchmark.rb
Created May 3, 2012 20:06
Benchmark Your Bundle
#!/usr/bin/env ruby
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
]
@dberringer
dberringer / myproject
Created June 20, 2011 19:21
bash project shortcut
myproject() {
cd /Users/doug/development/myproject/ && rvm 1.8.7
if [ "${1}" == "s" ]; then
script/server -u
fi
}
@TimFletcher
TimFletcher / run_gunicorn.sh
Created September 21, 2010 01:43
Gunicorn Management
#!/bin/sh
# You must have your virtualenv activated to run this script
NAME=gunicorn_timothyfletcher
PID=/home/fire/www/timothyfletcher.com/conf/gunicorn.pid
SETTINGS=/home/fire/www/timothyfletcher.com/timothyfletcher/settings.py
LOGFILE=/home/fire/www/timothyfletcher.com/logs/gunicorn.log
WORKERS=8
BIND_ADDRESS=127.0.0.1:8000
### subdomain_test.rb
require 'integration_test_helper'
class SubdomainTest < ActionController::IntegrationTest
test "simple subdomain test" do
sub1 = "sub1"
sub2 = "sub2"
# this test passes using selenium
#Capybara.current_driver = :selenium
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {