Skip to content

Instantly share code, notes, and snippets.

View lukaszkorecki's full-sized avatar
🌴
🛹

Łukasz Korecki lukaszkorecki

🌴
🛹
View GitHub Profile
@thewebfellas
thewebfellas / nginx.conf
Created January 28, 2009 16:19
sample nginx.conf for thin
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
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
@kevmoo
kevmoo / whitespace.rb
Created October 7, 2009 17:38
A ruby script for whitespace clean-up
#!/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)
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)
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
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
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"
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
};
@FiXato
FiXato / fliptext.rb
Last active March 1, 2017 23:34
A simple ruby script to 'flip' text using Unicode equivalents. Also see https://gist.github.com/FiXato/4969073 for Mathematical glyph support.
#!/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
// ----------------------------------------------------------
// 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) {}