This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 5; | |
error_log /var/log/nginx.error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In response to all the responses to: | |
http://twitter.com/rtomayko/status/1155906157 | |
You should never do this in a source file included with your library, | |
app, or tests: | |
require 'rubygems' | |
The system I use to manage my $LOAD_PATH is not your library/app/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Take a file_name | |
# If there are any "bad" lines: | |
# => Print out the file name | |
# => Print out the offending line numbers | |
# => Overwrite the file with "good" lines | |
# You might want to make sure *everything* is in source control first | |
# It's "good form" to have mass white-space clean-up be a single check-in, too | |
def clean_whitespace(file_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
class MyLogger < ActiveSupport::BufferedLogger | |
SEVERITY_NAME = %w( DEBUG INFO WARN ERROR FATAL UNKNOWN ) | |
def custom_line(severity, message) | |
# Customized Log Format! | |
message = [Time.now.strftime("%Y-%m-%d %H:%M:%S"), ENV['BL_JOB_ID']||$$, SEVERITY_NAME[severity], message].join("\t") | |
end | |
def add(severity, message = nil, progname = nil, &block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.38-osx10.5-x86_64/bin/mysql_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'json' | |
# sudo gem install json | |
# Usage example: | |
# putio = Putio.new("YOUR_API_KEY","YOUR_API_SECRET") | |
# puts JSON.parse(putio.user.friends.get) | |
# puts JSON.parse(putio.search :query => "massive attack" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = document.getElementById('myfileinput'); | |
var files = input.files; | |
var file = files[i]; | |
var xhr = new XMLHttpRequest(); | |
xhr.open('post', '/path/to/destination', true); | |
xhr.onreadystatechange = function() { | |
if (this.readyState != 4) { return; } | |
// request finished - handle response | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# A simple ruby script to 'flip' text using Unicode equivalents | |
# Based on the javascript code from http://www.revfad.com/flip.html | |
# TODO: also implement reverse lookup table. | |
class String | |
def each(&block) | |
(0...self.size).each do |idx| | |
block.call(self[idx,1]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE in JavaScript | |
// without resorting to user-agent sniffing | |
// ---------------------------------------------------------- | |
// If you're not in IE (or IE version is less than 5) then: | |
// ie === undefined | |
// If you're in IE (>=5) then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} |
OlderNewer