This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This patch detects {index_columns} that match something like | |
# the example below, then strips the surrounding double quotes. | |
# | |
# "(settings->'example')" | |
# | |
# The resulting CREATE INDEX sql looks something like: | |
# | |
# CREATE INDEX "idx_users_on_settings_example" ON "users" USING gin ((settings->>'example')) | |
# | |
# Your {add_index} call should looks something like: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage | |
# $ htpasswd.rb 'your_usrename', 'your_password' | |
# UseCase | |
# Generate htpasswd for nginx without apache tools. | |
require "base64" | |
username, password = ARGV | |
salt = Base64.encode64((("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..7].join) | |
puts "#{username}:#{password.crypt(salt)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Reactor | |
class Task | |
property :block | |
def initialize(timestamp=Time.now, milliseconds=0, &block : Loop ->) | |
@block = block | |
@timestamp = timestamp.epoch_ms | |
@milliseconds = milliseconds | |
end | |
def run reactor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
class Proc | |
def slow_callback(callable, *args) | |
self === Class.new do | |
method_name = callable.to_sym | |
define_method(method_name) { |&block| block.nil? ? true : block.call(*args) } | |
define_method("#{method_name}?") { true } | |
def method_missing(method_name, *args, &block) false; end | |
end.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bgp4r' | |
require 'yaml' | |
require 'observer' | |
require 'daemons' | |
include BGP | |
# Set this where your config file is | |
configFile = "/etc/bgp-daemon.conf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode:ruby;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*- | |
# vim: ft=ruby syn=ruby fileencoding=utf-8 sw=2 ts=2 ai eol et si | |
# | |
# build_rest-like_api.rb: sample REST-like API server | |
# (c) 2016 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below. | |
# | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"A blatant workman ripoff of bmx 007's beautiful colemak version called 'colqer' http://www.vim.org/scripts/script.php?script_id=2865 It makes vim so that you can insert and Ex mode in the workman keyboard layout, but can do the rest in qwerty. | |
"usage: put it in ~/.vim/plugin/ as workman.vim | |
"press \; in normal mode to activate/deactivate it. | |
"Keyboard is qwerty | |
" we want workman in insert mode | |
function IMapColemak() | |
if s:imap_colemak == 0 | |
noremap! q q | |
noremap! w d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In app/models/tableless.rb | |
class Tableless < ActiveRecord::Base | |
def self.columns | |
@columns ||= []; | |
end | |
def self.column(name, sql_type = nil, default = nil, null = true) | |
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, | |
sql_type.to_s, null) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Teamviewer | |
class Connector | |
attr_reader :client | |
def initialize | |
@client = connection(credentials) | |
end |
OlderNewer