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
@gotar
gotar / .vimrc
Created November 14, 2012 09:00
My vim rc
" Pathogen *******************************************************************
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" General ********************************************************************
set nocompatible
set encoding=utf-8
set fileencodings=utf-8,latin2
@gotar
gotar / pmap.rb
Last active December 10, 2015 17:18
require 'celluloid'
module Enumerable
# Parallel map. Calculates each element in a separate thread.
def pmap(timeout=nil, &block)
map {|element|
Celluloid::Future.new(element, &block)
}.map{|result|
begin
result.value(timeout)
@gotar
gotar / rapi.rb
Created April 2, 2013 13:56
Rapi - download subtitles
gotar@air ~/Programowanie/mamymo/Api [master] $ cat ~/Skrypty/Rapi/rapi
#!/usr/bin/env ruby
#encoding: utf-8
require "digest/md5"
require "open-uri"
class Rapi
def initialize avi_file_path
@avi_file_path = avi_file_path
%button.btn.dropdown-toggle{ "data-toggle"="dropdown }
Artice
%span
@gotar
gotar / .gitconfig
Created November 5, 2013 08:38
My ~/.gitconfig
[user]
name = Oskar Szrajer
email = oskarszrajer@gmail.com
[alias]
br = branch
co = checkout
ci = commit
df = diff
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@gotar
gotar / .bash_profile
Created November 8, 2013 11:44
.bash_profile
export EDITOR=mvim
alias l='ls'
alias g='git'
alias sl='shelly list'
alias sc='shelly console'
alias e='mvim'
alias bers='bundle exec rspec'
ll () {
@gotar
gotar / README.md
Created March 18, 2014 13:43 — forked from rantav/README.md

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...

---------------------------------------------------------------------------------------------------------
0,01 0,00 0,00 203/203 Mongoid::Fields::Validators::Macro.validate_name
0% 0% 0,01 0,00 0,00 203 Mongoid.destructive_fields
0,00 0,00 0,00 203/875 BasicObject#__send__
---------------------------------------------------------------------------------------------------------
0,00 0,00 0,00 2/149 NewRelic::Control::InstanceMethods.init_plugin
0,00 0,00 0,00 1/149 Module#alias_method_chain
0,00 0,00 0,00 74/149 Hash#inspect
0,00 0,00 0,00 72/149 Array#to_default_s
0% 0% 0,01 0,01 0,00 149 String#ins
Verifying that +gotar is my openname (Bitcoin username). https://onename.io/gotar
require 'lotus/validations'
module UserValidations
include Lotus::Validations
attribute :login, presence: true, format: /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/
attribute :password, presence: true, confirmation: true, size: 8..64
end
class User