Skip to content

Instantly share code, notes, and snippets.

@remyroez
remyroez / sugars.lua
Created February 25, 2020 11:21
lua syntax sugar for basic values(number, function, coroutine)
-- https://stackoverflow.com/questions/33988610/weird-behavior-of-syntax-sugarcolon-in-lua
local debug = require 'debug'
debug.setmetatable(0, { __index = math })
debug.setmetatable(function() end, { __index = coroutine })
debug.setmetatable(coroutine.create(function() end), { __index = coroutine })
local table = require 'table'
table.new = function (self, t)
t = t or self
@Rseding91
Rseding91 / MacroVariant.cpp
Created August 15, 2018 19:39
MacroVariant
#include <MacroVariant.hpp>
bool MacroVariant::isCorrectDataTypeForAction(MacroVariantType action, const std::type_info& type)
{
switch (action)
{
#define ADD_CASE(ACTION, PREFIX, TYPE, VALUE) \
case MacroVariantType::ACTION: return typeid(std::remove_cv<PREFIX TYPE>) == type;
CALL_ON_EVERY_TYPE_WITH_DATA(ADD_CASE)
#undef ADD_CASE
@john2x
john2x / 00_destructuring.md
Last active June 6, 2024 13:40
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@snipsnipsnip
snipsnipsnip / ants.exe
Last active December 19, 2019 20:30
ants.hsp
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"