Skip to content

Instantly share code, notes, and snippets.

Christian Takle christiantakle

  • Moixa
  • London
Block or report user

Report or block christiantakle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@christiantakle
christiantakle / fib.js
Last active Dec 10, 2015
Example of poormans pattern matching in Javascript. It useful in some cases. Beware of recursive definitions like this. It will blow the stack.
View fib.js
// Classic Javascript
function fib(n) {
if(n === 0) { return 0 }
if(n === 1) { return 1 }
return fib(n-1) + fib(n-2)}
// Non-auto-curry
const mkCases = // :: Object Functions -> a -> b
cases => key =>
(cases[key]? cases[key] : cases["_"])(key)
@christiantakle
christiantakle / diamond.js
Last active Aug 29, 2015
Solution for a codewars task
View diamond.js
var
CHAR = '*',
NEWLINE = '\n',
repeat =
function repeat(c, n) {
if(n === 0) { return ''; }
return c + repeat(c, n-1);
},
lines =
View 1.js
// fade out
function fade(el) {
var op = 1;
var timer = setInterval(function () {
if (op <= 0.1){
clearInterval(timer);
el.style.display = 'none';
}
el.style.opacity = op;
@christiantakle
christiantakle / navigation.haml
Last active Mar 28, 2016
Functional style, instead of adding conditional logic in the template use the fact that [] is a monoid. [a] + [] = [a] and [a] + [b] = [a,b]
View navigation.haml
:ruby
getAttrs = ->(link) {{href: link.fetch(:href), class: link.fetch(:class)}}
# Added to prevent typos in `tab_to_conf` and `mkLink`
events, following, calendar, overview, manager, followers, widget =
%w(events following calendar overview manager followers widget)
tab_to_conf =
{ calendar => [t('users.profile.calendar'), user_path(user)],
following => [t('users.profile.following'), following_user_path(user)],
View gist:9036e7809e75e5896d61
//-- Helpers ----------------------------------------------------------
@function push-get-size($key) {
$sizes: map-get($push-config, sizes);
@return map-get($sizes, $key);
}
//-- Config -----------------------------------------------------------
$push-spacing: util-rhythm(1);
$push-key-half: "-_5x"; // 0.5 | half
$push-key-double: "-2x";
View package.json
{
"dependencies": {
"jshint": "latest",
"uglifyjs": "latest",
"watch": "latest"
},
"config": {
"github_url": "https://api.github.com/repos/MarkBiesheuvel/markbiesheuvel.nl/commits?page=1&per_page=10",
"maps_url": "https://maps.googleapis.com/maps/api/staticmap?size=640x200&zoom=7&markers=color%3Ablue%7Clabel%3AH%7C51.469941%2C5.472258&markers=color%3Ayellow%7Clabel%3AW%7C51.574344%2C5.13781",
},
@christiantakle
christiantakle / Module: -> Bootstrap Grid Interface for ReactJS.js
Last active Aug 29, 2015
Generic Bootstrap Grid wrapper for ReactJS, WIP
View Module: -> Bootstrap Grid Interface for ReactJS.js
(function (exports, DOM, undefined) {
'use strict';
var namespace = 'ReactLayout';
// Data Column = Column { size :: Integer, component :: ReactComponent }
//-- Constants ------------------------------------------------------
var COLUMNS_TOTAL = 12,
CONTAINER = 'row-fluid',
CELL = 'span';
@christiantakle
christiantakle / Looking at instagram
Created Aug 8, 2014
@floydophone What is the style workflow @ instagram I see no styling loading in the network tab - but you're using class' in the markup.
View Looking at instagram
// In chrome dev-console
[].splice
.call(document.styleSheets,0)
.map(function(x){ return x.href })
// => [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
@christiantakle
christiantakle / First class z-index (CSS)
Created Aug 6, 2014
A good way keeping control of your used z-indexs to avoid confusing or bugs by choosing arbitary numbers
View First class z-index (CSS)
// _config.scss
$z-layers: (
bottomless-pit: -9999,
default: 1,
dropdown: 3000,
overlay: 4000
modal: 4001
);
// _functions.scss
@christiantakle
christiantakle / fromDomain
Created Jul 3, 2014
Naive implementaion of referrer tracking
View fromDomain
//-- Polyfill ---------------------------------------------------------
if ( !String.prototype.contains ) {
String.prototype.contains = function() {
return String.prototype.indexOf.apply( this, arguments ) !== -1;
};
}
//-- Module -----------------------------------------------------------
(function(exports, document, undefined) {
var namespace = 'tools';
You can’t perform that action at this time.