Skip to content

Instantly share code, notes, and snippets.

View gotar's full-sized avatar
🏠
Working from home

Oskar Szrajer gotar

🏠
Working from home
View GitHub Profile
@ericbn
ericbn / .vimrc
Last active March 31, 2024 10:39
Vim Powerline-like status line without the need of any plugin
" Statusline (requires Powerline font)
set statusline=
set statusline+=%(%{&buflisted?bufnr('%'):''}\ \ %)
set statusline+=%< " Truncate line here
set statusline+=%f\ " File path, as typed or relative to current directory
set statusline+=%{&modified?'+\ ':''}
set statusline+=%{&readonly?'\ ':''}
set statusline+=%= " Separation point between left and right aligned items
set statusline+=\ %{&filetype!=#''?&filetype:'none'}
set statusline+=%(\ %{(&bomb\|\|&fileencoding!~#'^$\\\|utf-8'?'\ '.&fileencoding.(&bomb?'-bom':''):'')
@rpanachi
rpanachi / db.rake
Created April 10, 2016 21:26
Rakefile for Sequel database operations
namespace :db do
require 'sequel'
Sequel.extension(:migration)
MIGRATIONS_PATH = 'db/migrations'
def db_conn_env
ENV["BOOKSHELF_DATABASE_URL"]
end
@solnic
solnic / rom-repo-crud.rb
Last active April 8, 2016 15:02
Upcoming rom-repository command support
require "rom-repository"
require "rom-sql"
config = ROM::Configuration.new(:sql, 'postgres://localhost/rom_repository')
class Users < ROM::Relation[:sql]
def by_id(id)
where(id: id)
end
end
@solnic
solnic / gist:9b9deedd7891e2c7ac83
Last active August 19, 2016 08:46
Virtus pg array type for Sequel
module Virtus
class PGArray < Attribute
primitive Sequel::Postgres::PGArray
def primitive
options[:primitive]
end
def coerce(value)
Sequel.pg_array(value)
@sabcio
sabcio / app.rb
Created April 10, 2014 08:32
require 'sinatra' on jruby 1.7.11
require 'jruby/profiler'
profile_data = JRuby::Profiler.profile do
require 'sinatra'
end
profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
profile_printer.printProfile(STDOUT)
@rantav
rantav / README.md
Created August 23, 2012 06:13
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...