Skip to content

Instantly share code, notes, and snippets.

run 'rm public/index.html'
gem 'paperclip'
generate :scaffold, 'user first_name:string last_name:string email:string login:string password:string'
generate :paperclip, 'user avatar'
route %[map.root :controller => 'users']
rake 'db:migrate'
run %[echo "class User < ActiveRecord::Base
has_attached_file :avatar, :styles => {:thumb => '100x100'}, :url => '/avatars/:id/:style'
validates_presence_of :first_name, :last_name, :email, :login, :password
@kucaahbe
kucaahbe / trace
Created October 5, 2011 19:50
pg segfault
# rake db:create:all
/home/kuca/.rvm/gems/ruby-1.9.2-p180@rorganizer/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:991: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
-- control frame ----------
c:0052 p:---- s:0192 b:0192 l:000191 d:000191 CFUNC :initialize
c:0051 p:---- s:0190 b:0190 l:000189 d:000189 CFUNC :new
c:0050 p:0020 s:0180 b:0180 l:000179 d:000179 METHOD /home/kuca/.rvm/gems/ruby-1.9.2-p180@rorganizer/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapte
c:0049 p:0055 s:0177 b:0177 l:000176 d:000176 METHOD /home/kuca/.rvm/gems/ruby-1.9.2-p180@rorganizer/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapte
c:0048 p:---- s:0170 b:0170 l:000169 d:000169 FINISH
@kucaahbe
kucaahbe / vhost.conf
Created June 29, 2012 10:10
nginx config file for rails + unicorn + gzipped assets + rails caching
upstream rails {
server 127.0.0.1:3000;
#server unix:/tmp/thin.0.sock;
}
server {
# we haven't checked to see if Rack::Deflate on the app server is
# faster or not than doing compression via nginx. It's easier
# to configure it all in one place here for static files and also
# to disable gzip for clients who don't get gzip/deflate right.
@kucaahbe
kucaahbe / simple.c
Created July 6, 2012 21:22
C dynamic arrays
#include <stdio.h>
#include <stdlib.h>
struct S {
int a;
};
int main()
{
struct S *arr=(struct S *) malloc(2*sizeof(struct S));
@kucaahbe
kucaahbe / gist:3293571
Last active October 8, 2015 06:39
simple mass string change
sed -i.bak -r 's/Gopa/Sraka/' $(grep -l -r Gopa config)
# for with git
sed -i.bak -r 's/Gopa/Sraka/' $(git grep -l admin)
@kucaahbe
kucaahbe / install-chromedriver.sh
Created August 13, 2012 12:34
chromedriver download and install script
#!/bin/sh
uname -m | grep 86 && ARCH=32
uname -m | grep 64 && ARCH=64
VERSION='21.0.1180.4'
URL="http://chromedriver.googlecode.com/files/chromedriver_linux${ARCH}_${VERSION}.zip"
mkdir -p $HOME/bin
ZIP_ARCH=$HOME/bin/chromedriver-$ARCH-$VERSION.zip
@kucaahbe
kucaahbe / install.sh
Created October 2, 2012 17:30
tuxguitar (debian testing)
sudo aptitude install tuxguitar tuxguitar-jsa timidity
http://followthegeeks.com/no-sound-in-tuxguitar-here-is-the-solution/
# run tuxguitar
# tools->settings->sound check "real time sequencer" and "gervill" there
@kucaahbe
kucaahbe / heroku.sh
Created November 1, 2012 10:44
Install custom ruby on heroku
#!/bin/sh
CURRENT_DIR=$PWD
RUBY_VERSION=1.9.3-p194-perf
# same path used for heroku, do not change
RUBY_BUILD_PATH=vendor/ruby-1.9.3
curl -L https://github.com/sstephenson/ruby-build/tarball/master | tar zx
@kucaahbe
kucaahbe / sed.sed
Created November 28, 2012 17:03
filter assets output
tail -f log/development.log | sed -r '/^Started\ GET\ \"\/assets\//,+5d'
@kucaahbe
kucaahbe / dotdeb.txt
Last active January 24, 2017 14:21
install redis on debian stable
add dotdeb repository: http://www.dotdeb.org/instructions/
sudo aptitude install redis-server # for stable
sudo aptitude -t stable install redis-server # for testing