Skip to content

Instantly share code, notes, and snippets.

View martinciu's full-sized avatar
😋
Wasup?

Marcin Ciunelis martinciu

😋
Wasup?
View GitHub Profile
require 'rom-mapper'
require 'json'
class ProfileMapper < ROM::Mapper
reject_keys true
attribute :id, from: "userId"
unwrap "profile" do
attribute :created_at, from: "firstDate"
# attribute :metric
# attribute :locale
{
"id": "1998",
"czas": "2013-02-20 09:27:00",
"debata_id": "1680",
"dzien_id": "312304",
"g": "438",
"l": "460",
"n": "22",
"numer": "5",
"p": "155",
SELECT c.relname AS Name,
pg_size_pretty(pg_relation_size(c.relname::text)) AS Data,
pg_size_pretty(pg_total_relation_size(c.relname::text)-
pg_relation_size(c.relname::text)) AS Indices,
pg_size_pretty(pg_total_relation_size(c.relname::text)) AS Total
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_table_is_visible(c.oid)
@martinciu
martinciu / Postgres Index Usage.sql
Created July 31, 2012 13:56 — forked from next2you/Postgres Index Usage.sql
Postgres: Determine table/index size
SELECT idx.relname as table,
idx.indexrelname as index,
pg_size_pretty(pg_relation_size( idx.indexrelname::text )) as bytes,
cls.relpages as pages,
cls.reltuples as tuples,
idx.idx_scan as scanned,
idx.idx_tup_read as read,
idx.idx_tup_fetch as fetched
FROM pg_stat_user_indexes idx,
pg_class cls ,
@martinciu
martinciu / nginx.conf
Created April 20, 2012 10:04
nginx.conf for dev rails ssl
#user nobody;
worker_processes 10;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
==> Downloading http://ftpmirror.gnu.org/clisp/release/2.49/clisp-2.49.tar.bz2
File already downloaded in /Users/martinciu/Library/Caches/Homebrew
/usr/bin/tar xf /Users/martinciu/Library/Caches/Homebrew/clisp-2.49.tar.bz2
==> Downloading patches
/usr/bin/curl -qf#LA Homebrew 0.8.1 (Ruby 1.8.7-249; Mac OS X 10.7.3) https://trac.macports.org/export/89054/trunk/dports/lang/clisp/files/patch-src_lispbibl_d.diff -o 001-homebrew.diff --silent
==> Patching
/usr/bin/patch -f -p0 -i 001-homebrew.diff
patching file src/lispbibl.d
==> ./configure --prefix=/usr/local/Cellar/clisp/2.49 --with-readline=yes
./configure --prefix=/usr/local/Cellar/clisp/2.49 --with-readline=yes
@martinciu
martinciu / gist:1195951
Created September 5, 2011 21:24
capistrano assets:precompile tack
namespace :deploy do
desc 'Bundle and minify the JS and CSS files'
task :precache_assets, :roles => :app do
run "cd #{release_path};RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
end
before 'deploy:symlink', 'deploy:precache_assets'
end
@martinciu
martinciu / README.markdown
Created July 23, 2011 19:46
me.rb - My entry to the CodeBrawl.com "Terminal admin" contes

me.rb

In almost every my project there is a model that refers to myself. It can be an instance of User, Staff, Admin, Dude, etc. I use it for logging in and testing staff. I use it many times in rails console as well. Because typing User.where(:email => 'my@email.com').first can by annoying so I've put together little snippet that work in Mongoid and AcitveRecord as well.

$ rails console
Loading development environment (Rails 3.1.0.rc4)
>> load 'me.rb'
=&gt; nil