Skip to content

Instantly share code, notes, and snippets.

View lisovskyvlad's full-sized avatar

Lisovskii Vladislav lisovskyvlad

View GitHub Profile
BEFORE:
sam@ubuntu discourse % rm -fr tmp/cache
sam@ubuntu discourse % rm -fr public/assets
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile
58.55s user 1.79s system 100% cpu 1:00.02 total
AFTER:
-module(web_lager_handler).
-behaviour(gen_event).
-export([subscribe/1, unsubscribe/1]).
-export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2,
code_change/3]).
-export([remover_loop/0]).
def check
yield
rescue => e
e
end
check { "hello, #{1}" } # ?
check { "hello, " + 1 } # ?
check { "hello, " << 1 } # ?
class A
def to_s
'A1'
end
def to_str
'A2'
end
end
@hom3chuk
hom3chuk / explain-weight.php
Last active August 29, 2015 14:00
Extend PostgreSQL query planner (EXPLAIN) logs with relative costs and times
#!/usr/bin/php5
<?php
/**
* Simple script to weight PostgreSQL query planner costs (`analyze` times included!) in explain log file.
* Handy for analyzing large query plans with a lot of subqueries.
* Example output (this scan took ~21% of total query run time, worth optimizing):
-> Seq Scan on public.tablename (cost=0.00..3919.54 rows=1 width=0) (actual time=64.232..86.516 rows=1 loops=1)
Cost: 0.00..22.35%
Time: 15.53..20.92%
Output: tablename.id, tablename.name, tablename.another_id
@ahoward
ahoward / a.rb
Last active August 29, 2015 14:01
make it print all 'true'
# fork it
#
# make it print all true with only ONE LINE OF CODE
class A
def A.foo
@foo ||= (
if self == A
'42.0'
else
@thomasklemm
thomasklemm / gist:0422fd71a96cfb4cb72a
Last active August 29, 2015 14:01 — forked from trcarden/gist:3295935
SSL on localhost, reusuable across multiple Rails apps
# SSL self signed localhost for rails start to finish, no red warnings.
# 0) Unless present, create `~/.ssl/`
$ mkdir ~/.ssl
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out ~/.ssl/localhost.orig.key 2048
@arr-ee
arr-ee / core.clj
Created July 4, 2014 22:16
Tiny Instapaper scraper
(ns instagroup.core
(:require [net.cgrand.enlive-html :as html]
[clj-http.client :as http]
[clj-http.cookies :as cookies]
[clojure.java.io :as io]
[clojure.string :as s]
[clojure.pprint :as pp])
(:import java.io.ByteArrayInputStream)
(:gen-class))
@mpakus
mpakus / gist:b969bce8b12ff2ec3bdf
Created October 8, 2014 05:01
select date angularjs directive (using: <div selectdate yu-model="user.birthdate_on"></div>)
.directive "selectdate", ($translate)->
restrict: 'A'
scope:
yuModel: '='
controller: ($scope, $element) ->
$scope.months = [
{value: 1, name: 'jan'},
{value: 2, name: 'feb'},
{value: 3, name: 'mar'},
{value: 4, name: 'apr'},
@vast
vast / gulpfile.coffee
Created February 24, 2015 18:49
gulp & postcss integration
gulp = require "gulp"
gutil = require "gulp-util"
plumber = require "gulp-plumber"
app_config = require "../config/application"
postprocessors = require "../config/postcss"
gulp.task "stylesheets", ["clean:stylesheets"], ->
gulp.src(app_config.paths.main_stylesheet)
.pipe(plumber())