Skip to content

Instantly share code, notes, and snippets.

View gogiel's full-sized avatar

Jan Jędrychowski gogiel

View GitHub Profile
@gogiel
gogiel / Vagrantfile
Created August 25, 2018 21:46
Docker-CE in Vagrant
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ kubectl describe job rails-example-app-migration-hxptn
Name: rails-example-app-migration-hxptn
Namespace: default
Selector: controller-uid=3bfd8456-7b07-11e8-b4ff-42010a9c0106
Labels: controller-uid=3bfd8456-7b07-11e8-b4ff-42010a9c0106
job-name=rails-example-app-migration-hxptn
Annotations: <none>
Parallelism: 1
Completions: 1
Start Time: Thu, 28 Jun 2018 21:12:43 +0200
@gogiel
gogiel / databases_helmfile.yaml
Created June 28, 2018 18:36
Rails databases setup on Kubernetes using Helm
releases:
- name: redis-sandbox
chart: stable/redis
values:
- redis.yml
- name: postgres-sandbox
chart: stable/postgresql
values:
- postgres.yml
ExUnit.start
defmodule EtsAssertion do
use ExUnit.Case
test "ets" do
:ets.new(:table, [:named_table, :bag])
:ets.insert(:table, [{:items, :a, :b, :c}, {:items, :a, :x, :x}])
result = :ets.match(:table, {:items, '$1', '$2', '_'})
assert result == [[:a, :b],[:a, :x]]
# Requires `brew install ag`
dirname = ARGV[0]
records = Dir.glob(File.join(dirname, "**/*"))
possible_extensions = %w(jpeg jpg svg gif png css scss js coffee htc ejs jst).map{|ext| ".#{ext}"}
names = records.
reject{|path| File.directory?(path) }.
reject{|path| path =~ /@2x/}.
map do |path|
@gogiel
gogiel / gist:a1fa827f5241bc543e4d
Created December 10, 2014 14:16
Find unused assets
# Requires `brew install ag`
dirname = ARGV[0]
records = Dir.glob(File.join(dirname, "**/*"))
possible_extensions = %w(jpeg jpg svg gif png css scss js coffee htc ejs jst).map{|ext| ".#{ext}"}
names = records.reject{|path| File.directory?(path) }.map do |path|
name = File.basename path
while true
ext = File.extname(name)
@gogiel
gogiel / a.rb
Created November 12, 2014 16:25
occurrences
@gogiel
gogiel / a.rb
Created November 7, 2014 12:27
vagrant@precise64:/vagrant$ sudo apt-get install libexif-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libexif12 libjs-jquery
Suggested packages:
javascript-common
The following NEW packages will be installed:
libexif-dev libexif12 libjs-jquery
@gogiel
gogiel / mastermind.rb
Created March 16, 2013 00:09
Mastermind, Knuth's solution in Ruby.
module Mastermind
class Color < Struct.new(:symbol)
def to_s
symbol.to_s
end
end
class Colors < Array
def all_possibilities(pegs_count)
repeated_permutation(pegs_count).map do |c|
@gogiel
gogiel / robot.js
Created December 4, 2012 18:31 — forked from randompast/robot.js
QR-bot-009
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
var rx = robot.position.x;
var ry = robot.position.y;
var aH = robot.arenaHeight;
var aW = robot.arenaWidth;
robot.clone()
};