Skip to content

Instantly share code, notes, and snippets.

View kek's full-sized avatar

Karl Eklund kek

  • Stockholm, Sweden
View GitHub Profile
### Keybase proof
I hereby claim:
* I am kek on github.
* I am karl_eklund (https://keybase.io/karl_eklund) on keybase.
* I have a public key ASAEcOPBQyycvkWS6x_PxR6X9b2g9eHICRaDPQqbsEhmrAo
To claim this, I am signing this object:
(defun generate-project-tags-table () (interactive)
(projectile-with-default-dir (projectile-project-root)
(start-process "ctags" "ctags" "ctags" "-Re" ".")))
(defun generate-and-then-load-project-tags-table () (interactive)
(if (projectile-project-p)
(let ((process (generate-project-tags-table)))
(set-process-sentinel process (lambda (_process event)
(if (string-match-p "finished" event)
(visit-project-tags-table)))))))
@kek
kek / gist:6906633
Last active December 25, 2015 02:59
Shadowing?
defmodule Main do
def f do
1
end
def run do
f = 2
f
end
end
@kek
kek / class.rb
Last active December 20, 2015 20:48
def rule message, &block
@rules ||= []
@rules << Class.new {
attr_reader :message
def initialize(message, &block)
@message = message
@block = block
end
class Player
attr_reader :warrior
def play_turn(warrior)
@warrior = warrior
if warrior.feel(:backward).captive?
@has_rescued = true
warrior.rescue!(:backward)
elsif not @has_rescued
@kek
kek / gist:3342113
Created August 13, 2012 15:53
Option type-like (?) extension for Object
class Object
def or(els)
if block_given?
yield (self or els)
else
els
end
end
end
@kek
kek / gist:3342046
Created August 13, 2012 15:43
Experiment with Object
class Object
def chain
yield self
end
end
puts 1.chain { |x| x + 1 }.chain { |x| x + 1 }
@kek
kek / gist:3153275
Created July 20, 2012 21:16
Writing a CGI script with templates. For PHP programmers
#!/usr/bin/ruby
require 'cgi'
require 'erb'
cgi = CGI.new('html')
template = <<TEMPLATE
<html>
<head>
\ 2520 is the smallest number that can be divided by each of the
\ numbers from 1 to 10 without any remainder.
\ What is the smallest positive number that is evenly divisible by all
\ of the numbers from 1 to 20?
: divisible-by-upto? { n upto -- bool }
0
upto 1+ 1 ?do
n i mod +
@kek
kek / eve.rb
Created October 30, 2009 12:23
eve online skill training queue checker
#!/usr/bin/env ruby
# Gist: https://gist.github.com/222304
# Install Nokogiri, http://nokogiri.rubyforge.org/nokogiri/
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# ~/.eve needs to contain user id, full api key and character id,