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 / gist:1347672
Created November 8, 2011 12:52
Delete commits from repository.
# First, check out the commit you wish to go back to (get sha-1 from git log)
git reset --hard 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a
# Then do a forced update.
git push origin +9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a^:develop
# Push specific commit
git push origin 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a:develop -f
@dsci
dsci / drop.sh
Created August 7, 2012 09:40
Dropping all tables in a PostgreSQL database
# first, login with psql
psql -U USERNAME -d databasename
# set output for all queries
\o FILENAME.sql
# run this query
select 'drop table ' || tablename || ' cascade;' from pg_tables;
# logout from psql
@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 / 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>
{
"cmd": ["bash", "-c", "clang -lobjc -framework Cocoa -framework Carbon -o /tmp/sublime-objc-output $file"],
"file_regex": "^(.*?):([0-9]+):([0-9]+): (.*)",
"selector": "source.objc",
"variants": [
{
"name": "Run",
"cmd": ["bash", "-c", "clang -lobjc -framework Cocoa -framework Carbon -o /tmp/sublime-objc-output $file && /tmp/sublime-objc-output"]
}
]