Skip to content

Instantly share code, notes, and snippets.

View raeffu's full-sized avatar

Raphael Breukel raeffu

  • University of Bern
  • Bern, Switzerland
View GitHub Profile

any vs. unknown type

TypeScript 3.0 introduces a new top type unknown. unknown is the type-safe counterpart of any. Anything is assignable to unknown, but unknown isn’t assignable to anything but itself and any without a type assertion or a control flow based narrowing. Likewise, no operations are permitted on an unknown without first asserting or narrowing to a more specific type.

Type Guards

  • DO use type gurads when you need to distinguish between type. You can use typeof and instaceof type guards if writing a type guard function is overkill.
@raeffu
raeffu / INSTALL.md
Last active June 15, 2018 09:11
Hombrew install emacs 25.3 formula

Manually install Emacs 25.3 with Homebrew

  1. Uninstall emacs with brew uninstall emacs or brew uninstall --ignore-dependencies emacs if you get a dependency error.
  2. Install emacs 25.3 with brew install --build-from-source https://gist.githubusercontent.com/raeffu/49de231b3b846bdb6ab9824a876221f0/raw/1c860b88c6a41146153a9376e807f2b397849eab/emacs.rb --with-cocoa
@raeffu
raeffu / tmux-cheatsheet.markdown
Last active September 15, 2015 12:00 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@raeffu
raeffu / analog_comparator.ino
Created May 22, 2015 09:31
Analog Comparator
#include <avr/interrupt.h>
#include <avr/io.h>
volatile int event = 0;
volatile unsigned long time;
volatile unsigned long startTime;
void setup() { //Initialisierungen
Serial.begin(9600); //Baudrate für serielle Kommunikation.
//ACSR = 3; //Analog Comperator fallende Flanke, externe Referenzspannung auf Pin D6
// ACSR = 2; //Analog Comperator steigendee Flanke, externe Referenzspannung auf Pin D6
@raeffu
raeffu / findCycleInGraph.java
Created February 9, 2015 12:26
find cycle in graph
private boolean findCycle(int[][] ad, int p, boolean[] visited) {
visited[p] = true;
for (int i = 0; i < ad.length; i++)
{
if(ad[p][i] == 1 && !visited[i])
return findCycle(ad, i, visited);
else if(ad[p][i] == 1 && visited[i]) // back-edge found --> has cycle
return true;
}
return false;
@raeffu
raeffu / FunctionFlip_on_OSX_Yosemite.md
Last active March 6, 2017 20:44
How to install FunctionFlip on OS X 10.10 (Yosemite)

Installation steps for FunctionFlip on OSX Yosemite

  1. Install FunctionFlip 2.2.2
  2. Open System Preferences, Security & Privacy > Privacy panel, Accessibility
  3. Open terminal
  4. If FunctionFlip is installed for all users go to step 6
  5. If FunctionFlip is installed only for current user go to step 7
  6. Enter open /Library/PreferencePanes/FunctionFlip.prefPane/Contents/Resources in terminal
  7. Enter open ~/Library/PreferencePanes/FunctionFlip.prefPane/Contents/Resources in terminal
  8. Drag and Drop FunctionFlip.app to the list of Accessibility-Apps in System Preferences you have opened in step 2.
@raeffu
raeffu / backtracking.java
Created January 9, 2014 08:54
pseudo code backtracking algorithmus sudoku
boolean solve(configuration conf){
if(no more choices) // BASE CASE
return (conf is goal state);
for(all available choices){
try one choice c;
if(solve(conf with choice c made)) return true;
unmake choice c;
}
@raeffu
raeffu / gist:8073014
Created December 21, 2013 18:30
git commands
rewrite (merge) commit, HEAD^ or older:
git checkout <sha of merge>
git commit --amend # edit message
git rebase HEAD previous_branch
https://github.com/schacon/showoff
github pages
git config --global merge.tool opendiff
@raeffu
raeffu / uninstall-xcode-dev-headers.sh
Created December 19, 2012 17:41
uninstall xcode dev headers
sudo /Developer/Library/uninstall-devtools –mode=all
@raeffu
raeffu / clearfix.css
Created November 17, 2012 18:34
CSS clearfix
/* clearfix */
.group:before,
.group:after {
content: "";
display: table;
}
.group:after {
clear: both;
}