Skip to content

Instantly share code, notes, and snippets.

View nikhedonia's full-sized avatar
💭
actively open-sourcing

Gaetano Checinski nikhedonia

💭
actively open-sourcing
View GitHub Profile
@nikhedonia
nikhedonia / async_generator.js
Created June 25, 2015 23:26
async_generator example
var Promise = require('promise');
function* counter(){
let i=0;
while(1){
yield i++;
}
}
function wait(time){
@nikhedonia
nikhedonia / ES7SQL.js
Last active August 29, 2015 14:27
ES7SQL
function extend(...args) {
let obj = this||{};
const l = args.length;
for (let i=0; i < l; i++) {
for (let k in args[i]) {
obj[k] = args[i][k];
}
}
return obj;
}
@nikhedonia
nikhedonia / example.cpp
Last active October 24, 2015 19:16
Opaque Functional MatrixType
#include <iostream>
using namespace std;
template<class Getter>
struct VectorF {
const size_t N;
Getter Get;
template<class T>
#include <type_traits>
#include <iostream>
using namespace std;
auto Valid = [](auto...x) -> integral_constant<bool,1> {};
template<class F,class...X>
constexpr auto is_callable(F f,X...x)
-> decltype( f(x...), true_type{} ) {
return{};
@nikhedonia
nikhedonia / contracts.cpp
Created November 10, 2015 21:14
buggy...
#include <iostream>
#include <array>
#include <tuple>
#include <type_traits>
#include <algorithm>
using namespace std;
auto Valid = [](auto...x) -> integral_constant<bool,1> {};
@nikhedonia
nikhedonia / linkedIn-invite-all.js
Last active August 15, 2016 00:47
invites everybody who shows up on your search page
function inviteAll(i, clickTime, loadTime) {
i = (i !== undefined) ? i : 100; // how many people you like to add ?
clickTime = clickTime||350; // how quick can a human click ?
loadTime = loadTime||1000; // wait till next page is loaded
if (i<=0) return;
var invite = document.
querySelector('a[href^="/people/invite"]:not(.invite-sent)');
// check if there a people to invite
if (invite) {
invite.click();
// Fibonacci
#include<math.h>
#include<vector>
// This slow machine will barely be able to compute Fib1(30)
// O(n!)
constexpr auto FibR(size_t n) {
// Type Erasure
// https://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil
// https://akrzemi1.wordpress.com/2013/11/18/type-erasure-part-i/
#include<memory>
#include<iostream>
struct Printable {
//SFINAE - Substitution-Failure-Is-Not-An-Error
template<bool condition, class T>
struct enable_if {
using type = T;
};
template<class T>
struct enable_if<false,T>
#include<iostream>
#include<vector>
#include<string>
#include<set>
auto numberOfUniqueChars(std::string const& str) {
std::set<char> s;
for(auto c : str) {
s.insert(c);
}