Skip to content

Instantly share code, notes, and snippets.

@bishboria
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
@nimaai
nimaai / macro-pitfalls.md
Last active February 4, 2024 21:37
Lisp macro pitfalls
@elbeno
elbeno / fix.cpp
Created May 16, 2015 21:58
Fixed-point (Y) combinator in C++
#include <functional>
#include <iostream>
using namespace std;
template <typename F>
struct Y
{
Y(F f) : m_f(f) {}
template <typename T>
@goldshtn
goldshtn / typelist_sort.cpp
Last active August 29, 2015 14:13
Sort a typelist by size at compile-time, using quicksort.
template <typename Predicate, typename Head, typename... Tail>
struct typelist_sort_t<Predicate, typelist<Head, Tail...>>
{
using predicate = meta_partial_apply<Predicate, Head>;
using notpredicate = meta_negate<predicate>;
using smaller_than = typelist_filter<notpredicate, typelist<Tail...>>;
using greater_than = typelist_filter<predicate, typelist<Tail...>>;
using type = typelist_cat<
typelist_sort<Predicate, smaller_than>,
typelist<Head>,
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@fogleman
fogleman / distinct.py
Last active December 1, 2020 05:07
Python Unique / Distinct Elements Iterator
def distinct(iterable, keyfunc=None):
seen = set()
for item in iterable:
key = item if keyfunc is None else keyfunc(item)
if key not in seen:
seen.add(key)
yield item
if __name__ == '__main__':
x = [0, 0, 1, 0, 1, 2, 2, 1, 0]
@mtetlow
mtetlow / exampleJS.js
Created June 3, 2013 15:54
This is a first pass at creating a Salesforce.com APEX Remote Action wrapper for jQuery deferred objects. This will allow you to utilize the jQuery.deferred methods (http://api.jquery.com/category/deferred-object/), and avoid lengthy strings of callback methods.
function remoteActionDeferredWrap(remoteActionMethod, paramArr, escape){
//Create the deferred object
var deferredObj=$j.Deferred();
//Create the callback method, this will manipulate the deferred object to show when complete
var callback = function(result,status){
if(status.status==true){
deferredObj.resolve(result);
}
else{
deferredObj.reject('Error: '+status.message);