Skip to content

Instantly share code, notes, and snippets.

@atd
atd / gist:99748101263d96611c52
Created April 15, 2015 16:01
Simple Python HTTP Server
python -m SimpleHTTPServer
# AttachmentFu sets the Attachment content type from the browser sent Content-type header
#
# This monkey patch uses UNIX file utility to fix broken or missing content types headers
module Technoweenie::AttachmentFu::InstanceMethods
def uploaded_data_with_unix_file_mime_type=(file_data)
tmp_file = self.uploaded_data_without_unix_file_mime_type=(file_data)
if tmp_file.present? && (unix_file = `which file`.chomp).present? && File.exists?(unix_file)
`#{ unix_file } -v 2>&1` =~ /^file-(.*)$/
@atd
atd / gist:721434
Created November 30, 2010 09:55
cijoe build-failed hook to send emails through sendmail
TO=`git show --pretty=email | grep ^From: | sed -e 's/^From: //'`
echo "From: sender
To: $TO
Cc: other-receiver
Subject: Tests failed!
Application was broken in the last commit!
You can check it at:
http://ci-web-address
# Quick script used to import social_stream-* tags to social_stream's repository
Dir["*tags"].inject({}) { |res, f|
res[f[0..-6]] = File.read(f).split("\n")
res
}.each_pair{ |repo, tags|
tags.each { |tag|
commit = `cd ../social_stream-#{ repo } && git show #{ tag }`.split("\n").
select{ |l| l =~ /^commit/ }.
first.
gsub("commit ", "")
DOCKER_OPTS="--storage-driver overlay --exec-opt native.cgroupdriver=cgroupfs"
@atd
atd / gist:1560638
Created January 4, 2012 15:51
MySQL new database and user
create database db_name;
grant all privileges on db_name.* to user_name@localhost identified by 'password';
@atd
atd / gist:1682261
Created January 26, 2012 11:04
Debug bundler dependencies
DEBUG_RESOLVER=true bundle
@atd
atd / gist:3754485
Created September 20, 2012 07:46
Compile ruby 1.8.7
CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls" rvm install 1.8.7
@atd
atd / gist:3852408
Created October 8, 2012 13:03
Vish branch
git log vish ^master --no-merges
* SWF support
* f6c529f875fe6096960f5e04fda1e55ec008b42c it works?
* d41a87b3b114f87717e4e248fce96b95bfe55c0e new form
* bb6eae831e033231bc57996d532ae0a1c9858ba3 it works?
* 161a9a91cf6ebd95cb9ac534506e8de6e884bd24 office document
* f6a0d47c18aa9ec493a0d7bce19cd643eb4a0a8d thumbnail styles for vish
* b529972d8a5bbdbbf24a18070b17a9fd17778e61 Create post_activity after draft only
* 7e0b5951311b2fa84cced8ca310054e0b65f760b and destroy???
@atd
atd / sort.js
Created November 12, 2015 10:02
// Sort json by object keys
function sortObject(object){
var sortedObj = {},
keys = Object.keys(object);
keys.sort(function(key1, key2){
key1 = key1.toLowerCase(), key2 = key2.toLowerCase();
if(key1 < key2) return -1;
if(key1 > key2) return 1;