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
View private.xml
<?xml version="1.0"?>
<root>
<item>
<name>Programmer's Shift Keys</name>
<!--
Author: Carwin Young (@carwin)
Last Updated: 2013.02.10
v.1.0
Programmer's Shift Keys
View git_tag.rb
#!/usr/bin/env ruby
tagname = ARGV.pop
def prompt(*args)
print(*args)
gets.chomp
end
if tagname.nil?
@christiantakle
christiantakle / Functional JavaScript - Example 1
Last active Dec 21, 2015
Simple Functional Example in JavaScript Using: `curry` and `compose`
View Functional JavaScript - Example 1
//-- Example 1 --------------------------------------------------------
//-- Note - We do not need to reference the data `email` when
//-- using a 'Point free style' of programming
//-- Note - `curry` is from Prelude. `compose` is from Oliver Steele --
//-- http://preludels.com/
//-- http://osteele.com/sources/javascript/functional/
//-- Imparative -------------------------------------------------------
var getUserName = function(email) {
@christiantakle
christiantakle / gist:7537088
Created Nov 18, 2013
Functional approach to bind, call and apply
View gist:7537088
var bind = Function.prototype.call.bind(Function.prototype.bind);
var call = bind(Function.prototype.call, Function.prototype.call);
var apply = bind(Function.prototype.call, Function.prototype.apply);
View conditional.js
// Ideas
//-- note (() -> IO), random function
//-- Maybe denote it with a lambda instead
//+ given :: (a -> Bool) -> (() -> IO) -> Maybe IO
//+ ifthen :: (a -> Bool) -> (() -> IO) -> Maybe IO
function ifthen(predicate, action) {
if (predicate()) {
action();
@christiantakle
christiantakle / composition_with_tap
Last active Jan 2, 2016
Using functional composition as before, around or after filter. This is a smart use of tap, to compose a sequence of functions that need somekind of sideeffect and provide a clear seperation of pure and impure functions
View composition_with_tap
//-- http://allong.es/try/
tap = allong.es.tap
flip = allong.es.flip
curry = allong.es.curry
compose = allong.es.compose
call = allong.es.call
//-- square :: Int -> Int
function square(x) { return x*x }
@christiantakle
christiantakle / closures?
Last active Jan 3, 2016
A function that illustrates closures and higher-order functions in JavaScript
View closures?
//-- If you understand closures - you know why this will always return true
function f(value) {
return (function (copy) {
return copy === value;
}(value));
}
@christiantakle
christiantakle / gist:9854444
Created Mar 29, 2014
Feedback on http://t.co/sFZYBp08bV - Sorry for being such an advocate for tap :)
View gist:9854444
def call(form_object)
form_object.validate!
if User.where(email: form_object.email).exists?
form_object.errros.add(:email, 'email already taken')
end
# Forgot to access the company_name attribute on the form_object
company = Company.create!(name: form_object.company_name)
User.create!(name: form_object.name, email: form_object.email, company: company)
@christiantakle
christiantakle / thunkify
Created Mar 31, 2014
//+ thunkify :: (... -> IO ()) -> ... -> ... -> IO ()
View thunkify
//+ thunkify :: (... -> IO ()) -> ... -> ... -> IO ()
function thunkify(fn /*, ... */) {
args = [].slice.call(arguments, 1);
return function(/* ... */) {
fn.apply(this, args.concat([].slice.call(arguments, 0)));
};
}
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
You can’t perform that action at this time.