Skip to content

Instantly share code, notes, and snippets.

Paul Maček macek

Block or report user

Report or block macek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@macek
macek / myFirst.py
Created May 19, 2010
My First Python
View myFirst.py
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters
Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
myParams = {
"server": "mpilgrim",
"database": "master",
"uid": "sa",
View affiliate_tree.txt
affiliate
+ referrals
| + referral
| | + player
| | | + rake
| | | + rake
| | + player
| | + rake
| + referral
| | + player
View monty_hall.rb
require "benchmark"
ITERATIONS = (ARGV[0] || 10000).to_i
def pick(set)
set[rand(set.size)]
end
def trial(method)
View Compile.tmCommand
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
response = Net::HTTP.post_form(
URI.parse("http://closure-compiler.appspot.com/compile"),
{
:js_code => STDIN.read,
@macek
macek / correct_crontab.sh
Created Sep 24, 2010
Running Rake tasks in Engine Yard Crontab
View correct_crontab.sh
cd /data/MyApp/current && /usr/bin/rake some:task
@macek
macek / advanced_output
Created Sep 24, 2010
Output Buffering with Ruby
View advanced_output
A contents <<<
send this to a
this goes to a
a, I forgot to add this
<<<
B contents <<<
this goes to b
b, please
<<<
@macek
macek / access_default_search.rb
Created Sep 24, 2010
Advanced Techniques for Searchlogic 2
View access_default_search.rb
# your custom search
@search = Product.search(params[:search])
# searchlogic default
@search = Product.searchlogic(params[:search])
@macek
macek / .htaccess
Created Sep 29, 2010
Redirect without www on Nginx and Engine Yard
View .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@macek
macek / 20101004063749_create_photos.rb
Created Oct 4, 2010
How to save uploaded files to your database in Rails
View 20101004063749_create_photos.rb
# db/migrate/20101004063749_create_photos.rb
class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.string :name, :null => false
t.binary :data, :null => false
t.string :filename
t.string :mime_type
t.timestamps
@macek
macek / Gemfile
Created Nov 16, 2010
Quick Sinatra App on Heroku
View Gemfile
source 'http://rubygems.org'
gem "sinatra"
You can’t perform that action at this time.