Skip to content

Instantly share code, notes, and snippets.

View releu's full-sized avatar
🕶️
I may be slow to respond.

Jan Bernacki releu

🕶️
I may be slow to respond.
View GitHub Profile
@releu
releu / es.sh
Created December 2, 2012 07:03
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.11.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@releu
releu / mountainlion.sh
Created July 25, 2012 11:59 — forked from AriX/mountainlion.sh
Script to check for Mac OS X 10.8 Mountain Lion
#!/bin/bash
while true; do
if curl -silent -A "iMacAppStore/1.0.1 (Macintosh; U; Intel Mac OS X 10.6.7; en) AppleWebKit/533.20.25" 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewMultiRoom?fcId=489264329&mt=12&s=143461' | grep -i "mountain lion" ; then
echo "Hello, Kitty"
say "MOUNTAIN LION IS AVAILABLE"
break
else
echo "Nope"
fi
sleep 120
@releu
releu / unsafe.js
Created June 12, 2012 19:09
test unsafe
<script>alert(1)</script>
@releu
releu / sqlite2pg.sh
Created May 26, 2012 05:30 — forked from eclubb/sqlite2pg.sh
Script to import SQLite3 database into PostgreSQL
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
@releu
releu / styleguide.md
Created May 25, 2012 08:25
coffeescript-style-guide

CoffeeScript Style Guide

This guide presents a collection of best-practices and coding conventions for the [CoffeeScript][coffeescript] programming language.

This guide is intended to be community-driven, and contributions are highly encouraged.

Please note that this is a work-in-progress: there is much more that can be specified, and some of the guidelines that have been specified may not be deemed to be idiomatic by the community (in which case, these offending guidelines will be modified or removed, as appropriate).

Inspiration

@releu
releu / mailer_spec.rb
Created April 26, 2012 15:40 — forked from thechrisoshow/mailer_spec.rb
Testing email delivery in Rails 3
it 'should send confirmation email' do
review = build(:review)
mailer = mock; mailer.should_receive(:deliver)
ReviewMailer.should_receive(:confirmation).with(review).and_return(mailer)
review.save
end
@releu
releu / inverse_of_simple_example.rb
Created April 26, 2012 06:07
Working example of inverse_of
class Post < AR::Base
has_many :comments, :inverse_of => :post
end
class Comment < AR::Base
belongs_to :post, :inverse_of => :comments
end
Comment.new.build_posts.comments == [Comment]
@releu
releu / inverse_of_example.rb
Created April 26, 2012 06:05
Inverse of doesn't work.
class Communication::Message < ActiveRecord::Base
belongs_to :conversation_for_proposal, {
:class_name => 'Communication::Conversation::ForProposal',
:foreign_key => :conversation_id,
:inverse_of => :messages_for_proposal
}
end
class Communication::Conversation::ForProposal < ActiveRecord::Base
has_many :messages_for_proposal, {
@releu
releu / understandable_code.rb
Created April 16, 2012 06:36
Two ways of determining parameter
def filter(params_or_filter)
params = if params_or_filter.is_a?(Hash)
params_or_filter
else
params_or_filter.conditions
end
# ...
end
def filter(params_or_filter)
@releu
releu / letlet.rb
Created April 12, 2012 08:11
rspec: let and let!
describe(:let) do
let(:smth) { Smth.create! }
it { Smth.count.should == 0 }
it { smth; Smth.count.should == 1 }
end
describe(:let!) do
let!(:smth) { Smth.create! }
it { Smth.count.should == 1 }
end