Skip to content

Instantly share code, notes, and snippets.

View sklppr's full-sized avatar

Sebastian sklppr

  • Munich, Germany
View GitHub Profile
@sklppr
sklppr / compare-langs.md
Created April 21, 2014 12:01
Comparison of simple actions in different languages.

Select all elements in a that are greater than 5 and multiply them by 2.

Ruby

a.select { |x| x > 5 }.map { |x| x * 2 }

a.find_all { |x| x > 5 }.collect { |x| x * 2 }

a.inject([]) { |b, x| x > 5 ? (b << x * 2) : b }
@sklppr
sklppr / twitter-friends.rb
Created September 13, 2012 15:26
Fetches info about the people you follow on Twitter and determines who you could/should unfollow.
# encoding: utf-8
#####################################################################################
#
# Fetches info about the people you follow on Twitter
# and determines who you could/should unfollow based on:
# - activity: was their last update more than 3 months ago?
# - popularity: do they have less than 25 followers?
# - mass following: are they following more than 10000 people?
@sklppr
sklppr / books-on-design.md
Created September 15, 2012 21:58
Books on Design

Books on Design

General

Design is a Job (Mike Monteiro)
The Design of Everyday Things (Don Norman)
Emotional Design (Don Norman)
Universal Principles of Design: A Cross-Disciplinary Reference (William Lidwell)
Designed for Use (Lukas Mathis)
The Shape of Design (Frank Chimero)

@sklppr
sklppr / markdown2html.rb
Last active December 30, 2015 08:39 — forked from brentsimmons/generate_html.rb
Batch conversion of Markdown to HTML.
#!/usr/bin/env ruby
require "fileutils"
require "redcarpet"
OUTPUT_FOLDER = "html"
HTML_TEMPLATE = <<-HTML
<!DOCTYPE html>
<html>
@sklppr
sklppr / coupon.rb
Created January 28, 2014 12:05
Coupon code generator with customizable number of parts, number of characters per part and separator.
def coupon(parts: 4, chars: 4, separator: "-")
SecureRandom.hex(parts*chars/2).upcase.scan(%r/.{#{chars}}/).join(separator)
end
@sklppr
sklppr / mac-checklist.md
Created March 30, 2012 11:36
Mac Checkliste

Mac Checklist

Important things when doing a clean install of Mac OS X

Setup

Backup

  • Contacts
  • Calendar
module Tree0 {
type Tree<T> = Empty | Node<T>;
class Empty {
public toString(): string {
return "Empty";
}
}
@sklppr
sklppr / r.sh
Last active May 16, 2019 20:34
#!/bin/bash
# Install a custom R version, https://www.r-project.org/
#
# Add at least the following environment variables to your project configuration
# (otherwise the defaults below will be used).
# * R_VERSION
#
# Include in your builds via
# source /dev/stdin <<< "$(curl -sSL https://gist.githubusercontent.com/sklppr/cec1b80642e02a12d4e57bc51d803c2e/raw/089ca9b56d6b2364df29db4e78039c3404ce437f/r.sh)"
R_VERSION=${R_VERSION:="3.3.0"}
@sklppr
sklppr / 5_reflection.rb
Created September 2, 2016 06:52
Immutable domain model
module SnakeCase
refine String do
def snake_case
self.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
.tr("-", "_")
.downcase
end
end
@sklppr
sklppr / forwardable.rb
Last active May 16, 2019 20:34
Separating model from ActiveRecord with delegation/decorator pattern.
require "forwardable"
module ActiveRecord
class Base
def save
puts "SAVED #{name}"
end