Skip to content

Instantly share code, notes, and snippets.

View lwe's full-sized avatar
💭
I may be slow to respond.

Lukas Westermann lwe

💭
I may be slow to respond.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lwe on github.
  • I am lwe (https://keybase.io/lwe) on keybase.
  • I have a public key ASBR3o4RHUCJWVKn-5UvI43Qry8SjTb6YzhWGhdK__YOYwo

To claim this, I am signing this object:

@lwe
lwe / hapi.js
Last active September 11, 2022 12:51
Server-sent-events with trial for hapi and one with a plain node.js http server.
var Hapi = require('hapi');
var stream = require('stream');
// Create a server
var server = Hapi.createServer('localhost', 8000);
// Add a route
server.route({
method: 'GET',
path: '/hello',
@lwe
lwe / Gemfile
Last active December 14, 2015 05:59
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.beta1'
gem 'sqlite3'
# THIS BREAKS IT, though when it's at the end of the file it works...
gem 'haml', '~> 3.1'
require 'sidekiq'
require 'sidekiq/manager'
require 'sidekiq/scheduled'
class SidekiqService
attr_reader :options, :manager
def initialize(options = {})
@options = options
@lwe
lwe / _rbfu.zsh
Created July 3, 2012 18:00
rbfu autocompletion for zsh
#compdef rbfu
local curcontext="$curcontext" state line _rubies _rubies_dir ret=1
_arguments -w -S \
'(-)--help[show usage and exit]: :->noargs' \
'1: :->versions' \
'*::: :->args' && ret=0
case $state in
@lwe
lwe / unscoped.rb
Created June 13, 2012 10:37
Module which provides the ability to unscope associations
# Provides the ability to unscope associations, this solves problems described in
# http://stackoverflow.com/questions/1540645/how-to-disable-default-scope-for-a-belongs-to/11012633#11012633
#
# Examples
#
# class Document < ActiveRecord::Base
# default_scope where(deleted: false)
# end
#
# class Comment < ActiveRecord::Base
{
"took" : 45,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 4,
@lwe
lwe / fail.rb
Created December 20, 2011 13:50
require 'rubygems'
require 'nokogiri'
puts "Platform: #{RUBY_PLATFORM}"
puts "Nokogiri: #{Nokogiri::VERSION}"
xml = <<XML
<foo:bar>
<some>value</some>
<other>1234</other>
@lwe
lwe / serveme
Created August 18, 2011 14:32
Start a simple HTTP server to serve current directory.
#!/usr/bin/ruby -w
require 'rubygems'
require 'optparse'
require 'rack'
# setup options
options = { :Port => 4000, :Host => "0.0.0.0" }
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: serveme [-p PORT] [-h HOST] [-s thin|webrick|...]"
module TelHelper
# Erstellt einen <a href="tel:..."> link.
def tel_to(telephone_number, name = nil, html_options = {})
href = html_escape telephone_number.to_s.strip.sub(/\A\+/, '00').gsub(/(\(.+\))/, '').gsub(/[^\d]/, '')
content_tag "a", name || telephone_number, html_options.stringify_keys.merge("href" => "tel:#{href}".html_safe)
end
end