Skip to content

Instantly share code, notes, and snippets.

<!doctype>
<html>
<head>
<script src="/app/components/rivets/dist/rivets.js"></script>
<script src="/app/components/ChangeSummary/change_summary.js"></script>
<script src="/app/components/lodash/lodash.js"></script>
</head>
<body>
<ul>
@felixlaumon
felixlaumon / rivets-each-binder.js
Created July 17, 2013 11:35
Rivets.js each=* binder in JavaScript
rivets.binders['each-*'] = {
block: true,
bind: function (el) {
var attr = ['data', this.view.config.prefix, this.type]
.join('-')
.replace('--', '-');
var declaration = el.getAttribute(attr);
var comment = ' rivets: ' + this.type + ' ';
this.iterated = [];
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
@felixlaumon
felixlaumon / jquery-fastdom-promise.js
Created November 12, 2013 05:19
jquery-fastdom-promise
$.when($('#id').height(), $('#id').width(), function (height, width) {
});
// instead of
$('#id').height(function (height) {
$('#id').width(function (width) {
});
//CodePen Evaluation License
//
//Copyright (c) 2013 Famo.us, Inc.
//
// Non-sublicensable permission is hereby granted, free of charge,
// to any person obtaining a copy of this software and associated
// documentation files directly from codepen.io (the "Software"), solely to
// internally make and internally use copies of the Software to test,
// explore, and evaluate the Software solely in such person’s non-commercial,
// non-production environments, provided that the above copyright
(function () {
try {
var orcWidth = parseInt(window.location.search.match(/width=(\d+)/)[1], 10);
var orcHeight = parseInt(window.location.search.match(/height=(\d+)/)[1], 10);
var hasFailed = window.location.search.match(/oswidthheight=(\w+)/);
if (hasFailed && hasFailed.length) {
console.log('ignore width height verification because it has failed once before');
return;
}
// Wraps a promise-returning `fn` so that `fn` will only be invoked
// one after another (no 2 concurrent calls)
function sequential (fn) {
var lastPromise = $.Deferred().resolve().promise();
return function () {
var context = this;
var args = arguments;
lastPromise = lastPromise.then(function () {
return fn.apply(context, args);
def helloworld():
return 'helloworld'
@felixlaumon
felixlaumon / matrix.py
Created August 27, 2014 15:22
matrix * vector without using itertool and mul
matrix = [
[1,3,9,2],
[2,4,6,8]
]
vector = [2,3,6,5]
def dot_product (a, b):
return sum(map(lambda x: x[0] * x[1], zip(a, b)))