Skip to content

Instantly share code, notes, and snippets.

View tinyurl.js
var tinyurl = "http://tinyurl.com/"
var urls = []
var encode = function(longUrl){
urls.push(longUrl)
return tinyurl+(urls.length-1)
};
var decode = function(shortUrl){
var index = Number(shortUrl.substring(tinyurl.length))
@rilerez
rilerez / wm.hpp
Last active Jan 9, 2019
with macros
View wm.hpp
#define WM_GENSYM(name) GENSYM_##name##__COUNTER__
#define WM_WITH(initializer,body) {auto WM_GENSYM() = initializer; body}
View hello-world.cpp
#include <iostream>
int main()
{
std::cout << "hello world\n";
std::getchar();
return 0;
}
@rilerez
rilerez / Y.hpp
Created Dec 22, 2018
Y Combinator in C++2a
View Y.hpp
#include <utility>
template <class F>
struct Y{
F f;
Y(F _f) : f{_f} {}
template<class...arg_t>
auto operator()(arg_t&&...arg) {return f(*this,std::forward<arg_t>(arg)...);}
};