Skip to content

Instantly share code, notes, and snippets.

View fidel-karsto's full-sized avatar
🚀
¯\_(ツ)_/

Karsten Rieger fidel-karsto

🚀
¯\_(ツ)_/
View GitHub Profile
@fidel-karsto
fidel-karsto / booksByList.js
Created January 29, 2020 20:36
Simple array destructuring
const booksList = [
'1',
'The Stranger\nThe Outsider',
'Albert Camus',
'1942',
'French',
'2',
'In Search of Lost Time\nRemembrance of Things Past',
'Marcel Proust',
'1913–27',
@fidel-karsto
fidel-karsto / git-remove-merged-branche.sh
Created November 13, 2019 20:59
remove all local branches that have been merged and deleted on remote
#!/usr/bin/env bash
# removes all remote deleted branches from local sandbox
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
@fidel-karsto
fidel-karsto / sh
Created February 12, 2019 16:49
git reset branch to initial state
git reset $(git merge-base master $(git rev-parse --abbrev-ref HEAD))
@fidel-karsto
fidel-karsto / git-cheat-sheet.md
Created February 11, 2019 08:40 — forked from barbara-rogar/git-cheat-sheet.md
List of helpful git commands

Git cheat sheet

Set up

Set up global .gitignore

git config --global core.excludesfile '~/.gitignore'

Set upstream

@fidel-karsto
fidel-karsto / koObservableArrayGetAsyncTwin.js
Created July 29, 2016 13:48
ObservableArray.getAsyncTwin() for Knockout
/**
* Adds a `getAsyncTwin()` method to the prototype of Knockout's ObservableArray
* returning a new ObservableArray that will be a continuous non-instant copy of the original.
* Whenever the original ObservableArray changes, the copy will be populated
* in chunks of a given size and with a given delay between the chunks until it is identical to the original.
*
* Intended to allow rendering the first (visible) part of huge lists faster before all the rest.
*
* Example:
*
// UMD dance - https://github.com/umdjs/umd
!function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(root.jQuery);
}
}(this, function($) {
'use strict';
@fidel-karsto
fidel-karsto / grid.less
Created April 2, 2015 20:24
Example of a dynamic responsive grid system.
// DyRGS - dynamic responsive grid system
// @author: karsten.rieger@tritium-design.de
@gutter: 1.5625%; // ~= 10px gutter @ 320px width
@mobile-column-count: 4;
@tablet-column-count: 8;
@desktop-column-count: 12;
@mobile-selector: m;
@tablet-selector: t;
@desktop-selector: d;
Array.prototype.shuffle = Array.prototype.shuffle || (function () {
function shuffle(array) {
var currentIndex = array.length
, temporaryValue
, randomIndex
;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
@fidel-karsto
fidel-karsto / aop.js
Created August 22, 2013 11:53
Some basic AOP style functions.
var before = function(fn, pre) {
return function() {
pre.apply(this, arguments);
return fn.apply(this, arguments);
};
},
after = function(fn, aft) {
return function() {
var result = fn.apply(this, arguments);
aft.apply(this, result);
@fidel-karsto
fidel-karsto / calculusCollection.js
Last active December 20, 2015 17:29
some calculations that might come in handy some time.
/*
Problem: how many collectible packets need to be bought to achieve a complete set,
when you don't know which one is in the packet.
i.e. There are 16 unique trading cards to complete a set. Each is sold in a sealed enclosing.
How many of them would it take to collect all 16?
answer: about 54!
https://plus.google.com/u/0/104223386721240823159/posts/goRYigJ4RGB
*/
var countCollectibles = function (collectibleCount) {
var eulerConstant = 0.5772156649;