Skip to content

Instantly share code, notes, and snippets.

View dsci's full-sized avatar

Daniel Schmidt dsci

  • Leipzig, Germany
View GitHub Profile
@dsci
dsci / duck.spec.ts
Created July 15, 2019 18:40
Strategy Pattern - Typescript // Duck Behaviour
import { expect } from 'chai';
import 'mocha';
import {
FlyWithWings,
FlyNoWay,
Quack,
MuteQuack,
Duck,
DuckWithAlternativeConstructor
@dsci
dsci / reflection.php
Created November 12, 2018 14:30
Reflection PHP
<?php
// example code
function dynamicCall($someMsg) {
try {
$method = new ReflectionMethod('Foo', $someMsg);
$method->invoke(new Foo());
}catch(Exception $error){
exitTheHell($error);
}
class SingletonCvar
def self.instance
@@instance ||= new
end
private_class_method :new
end
singleton = SingletonCvar.instance
@dsci
dsci / rake.rb
Last active February 2, 2016 07:28
Rake Tasks from classes
# Use instance methods of classes as Rake tasks:
#
# In a folder tasks, create your classes.
#
# class FooTask
# extend RakeDecorator
#
# task :numbers, desc: 'A funny task that prints out the first 10 numbers'
# def print_numbers_task
# puts (1..10).to_a.join(',')
@dsci
dsci / private_accessing.rb
Last active August 29, 2015 14:23
private_accessing.rb
class Bar
def self.foobar
end
private_class_method :foobar
end
@dsci
dsci / Dockerfile
Last active August 29, 2015 14:19 — forked from konklone/Dockerfile
Rachel Dockersetup
FROM ubuntu
MAINTAINER ''
# Needed?
# turn on universe packages
#RUN echo "deb http://archive.ubuntu.com/ubuntu raring main universe" > /etc/apt/sources.list
# Prepare Ubuntu and Rachel dependencies
RUN apt-get update
RUN apt-get install -y build_essential

How To: Authlogic to Devise

Step 1: Migration

  1. bin/rails g migration AuthlogicToDevise
  2. (see the file below for the actual migration, authlogic_to_devise.rb)
  3. bin/rake db:migrate

Step 2: Update Gemfile

  1. gem "devise", "~> 2.2.0"
  2. bundle install
@dsci
dsci / A-Pen-by-Daniel-Schmidt.markdown
Created January 9, 2014 07:03
A Pen by Daniel Schmidt.
@dsci
dsci / mono.rb
Last active December 26, 2015 04:49 — forked from shtirlic/mono.rb
# http://www.mono-project.com/Compiling_Mono_on_OSX
require 'formula'
class Mono < Formula
url 'http://download.mono-project.com/sources/mono/mono-3.2.3.tar.bz2'
sha1 'e356280ae45beaac6476824d551b094cd12e03b9'
homepage 'http://www.mono-project.com/'
@dsci
dsci / index.html
Created August 5, 2013 14:26
A CodePen by Daniel Schmidt.
<canvas id="404" width="600" height="600"></canvas>