Skip to content

Instantly share code, notes, and snippets.

Karl Eklund kek

View GitHub Profile
View gist:5f0e5f049cab745326ae682b68c2aeee
### 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:
View generate-tags-file-on-save.el
(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 Dec 25, 2015
Shadowing?
View gist:6906633
defmodule Main do
def f do
1
end
def run do
f = 2
f
end
end
View class.rb
def rule message, &block
@rules ||= []
@rules << Class.new {
attr_reader :message
def initialize(message, &block)
@message = message
@block = block
end
View rubywarrior6.rb
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 Aug 13, 2012
Option type-like (?) extension for Object
View gist:3342113
class Object
def or(els)
if block_given?
yield (self or els)
else
els
end
end
end
@kek
kek / gist:3342046
Created Aug 13, 2012
Experiment with Object
View gist:3342046
class Object
def chain
yield self
end
end
puts 1.chain { |x| x + 1 }.chain { |x| x + 1 }
@kek
kek / gist:3153275
Created Jul 20, 2012
Writing a CGI script with templates. For PHP programmers
View gist:3153275
#!/usr/bin/ruby
require 'cgi'
require 'erb'
cgi = CGI.new('html')
template = <<TEMPLATE
<html>
<head>
View gist:2377257
\ 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 Oct 30, 2009
eve online skill training queue checker
View eve.rb
#!/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,
You can’t perform that action at this time.