Skip to content

Instantly share code, notes, and snippets.


Mikhail S. Pabalavets styx

View GitHub Profile
styx / 0_reuse_code.js
Created Jan 10, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View dynamic_method_spec.rb
require 'spec/support/grep_matcher'
describe do
disallow_presence_of pattern: "send(.*#",
location: "app/",
description: "Do not use dynamic method invocations",
failure: "Please change dynamic method call to something more sane."
View gol.exs
defmodule Life do
def run(board) when is_binary(board) do
board |> parse_board |> run
def run(board) do
Life.print_board board
:timer.sleep 1000
board = next_board(board)
View resque.rake
# see - old version
# see
# see - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
View histogram.ex
defmodule NumbersInput do
def start do, :line)
|> Stream.flat_map(&tokenize/1)
|> Stream.take_while(&(&1 > -1))
defp tokenize(line) do
|> String.split(" ")
View histogram.exs
defmodule Lab05 do
@doc """
My take on [the histogram exercise]
mentioned in [this newsgroup post]
def main(), do: parse_pars(System.argv, nil)
defp parse_pars([],nil), do: histogram()
View ipow.ex
defmodule IntMath do
use Bitwise
def pow(_, 0), do: 1
def pow(a, 1), do: a
def pow(a, n) when band(n, 1) === 0 do
tmp = pow(a, n >>> 1)
tmp * tmp
View _output
$ ls
$ elixir thing.exs
calling other
other thing!
View app.js
* Angular needs to send the Rails CSRF token with each post request.
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %>
* is present in your layout.)
// configure our http requests to include the Rails CSRF token
config(["$httpProvider", function(p) {
var m = document.getElementsByTagName('meta');
View databases.rake
# #{Rails.root}/lib/tasks/databases.rake
Monkey Patch
clears obstinate stale PG session to get parallel_tests working
also, PG user must be superuser to use these low level PG functions
def drop_database(config)
case config['adapter']
when /mysql/