Skip to content

Instantly share code, notes, and snippets.

View lisovskyvlad's full-sized avatar

Lisovskii Vladislav lisovskyvlad

View GitHub Profile
@revolunet
revolunet / chrome.sh
Last active October 2, 2018 20:40
Launch a new chrome instance with disable-web-security
#!/bin/sh
# on OSX : /Applications/Google\ Chrome\ 2.app/Contents/MacOS/Google\ Chrome
/path/to/Chrome --user-data-dir=/tmp/test1 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-web-security
@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
@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
@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
@peterhellberg
peterhellberg / api.go
Last active January 18, 2019 01:58
A tiny example API written in Go using Martini and Redigo
package main
import (
"flag"
"fmt"
"net/http"
"github.com/codegangsta/martini"
"github.com/garyburd/redigo/redis"
"github.com/martini-contrib/render"
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
ConfirmedGrouperEmails.new(@grouper).deliver
AssignBarForGrouper.enqueue(@grouper.id)
redirect_to home_path
else
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
-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]).
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: