Skip to content

Instantly share code, notes, and snippets.

View atsjj's full-sized avatar

Steve Jabour atsjj

View GitHub Profile
@uhlenbrock
uhlenbrock / deploy.rb
Created December 14, 2011 17:36
Precompile assets locally for Capistrano deploy
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
@dawsontoth
dawsontoth / populateYUVLuminanceFromRGB.java
Created November 29, 2011 16:48
How to take a Bitmap (in RGB) and grab the luminance values for YUV. Useful for passing an image to ZXing for processing.
public void handleBitmap(Bitmap image) {
int w = image.getWidth(), h = image.getHeight();
int[] rgb = new int[w * h];
byte[] yuv = new byte[w * h];
image.getPixels(rgb, 0, w, 0, 0, w, h);
populateYUVLuminanceFromRGB(rgb, yuv, w, h);
}
// Inspired in large part by:
@telamon
telamon / socksproxy.js
Created August 5, 2011 12:42
Socks5 proxy implementation in Node.JS
// http://www.ietf.org/rfc/rfc1928.txt
// Tested with: curl http://www.google.se/ --socks5 1080 --proxy-user foo:bar
var States = {
CONNECTED:0,
VERIFYING:1,
READY:2,
PROXY: 3
};
@bmarini
bmarini / default.vcl.pl
Created June 30, 2011 18:01
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
@jmhobbs
jmhobbs / pptpd.sh
Created May 1, 2011 14:33
Ubuntu 11.04 AWS EC2 PPTPD Installer
#!/bin/bash
#
# This script will install and configure a PPTPD server on your Ubuntu box.
# I use this for a micro instance on Amazon EC2 as a quick, cheap (free!) VPN
#
# This script was tested with Natty Narwahl 11.04, ami-06ad526f
#
# Usage:
# wget https://gist.github.com/raw/950539/pptpd.sh
@nz
nz / Delete all documents in a Solr index using curl.md
Last active February 12, 2024 10:55
Delete all documents in a Solr index using curl
# http://wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F
# http://wiki.apache.org/solr/UpdateXmlMessages#Updating_a_Data_Record_via_curl

curl "http://index.websolr.com/solr/a0b1c2d3/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'

I'm amused at the traction this little gist is getting on Google! I would be remiss not to point out that six+ years later I'm still helping thousands of companies on a daily basis with their search index management, by providing managed Solr as a service over at Websolr, and hosted Elasticsearch at Bonsai. Check us out if you'd like an expert helping hand at Solr and Elasticsearch hosting, ops and support!

# Usage example:
#
# Main.register Sinatra::UserAgentHelpers
#
# -# haml
# %body{class: browser.body_class}
#
# - if browser.ios?
# %script{:language => 'text/javascript', :src => '/js/jqtouch.js'}
# %p Download our mobile app in the iTunes store!