Skip to content

Instantly share code, notes, and snippets.

package lambdas;
import sun.reflect.ConstantPool;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class TypeTest {
@FunctionalInterface
@bamboo
bamboo / AssemblyAttributeTriggerSpike.boo
Last active December 26, 2015 01:29
Using assembly attributes to trigger code transformations
namespace Spikes
import Boo.Lang.PatternMatching
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.MetaProgramming
class EnableResponsePatternAttribute(AbstractAstAttribute):
override def Apply(node as Node):
node.Accept(ResponseTransformer())
@legastero
legastero / gist:7127532
Last active December 26, 2015 09:09
Where to find XMPP/Jingle in JS resources

How are classes different from traditional functions?

ES6 introduced a new protocol for constructing instances, but its features (incl. new.target) work in both classes and traditional functions. These are the differences between traditional functions and classes:

  • Traditional functions can’t make superconstructor calls via super(). That means that they are always base classes. In ES5, superconstructors are called as functions.

  • The prototype of traditional functions and base classes is Function.prototype. The prototype of a derived class is its superclass.

  • Classes can’t be function-called. An exception is thrown if you do.

@legastero
legastero / prosody-setup.lua
Last active February 24, 2019 12:11
Set up a Prosody server to work with stanza.io/otalk (with websockets, mam, etc)
-- 1. apt-get install prosody-trunk
-- 2. Checkout prosody-modules on Google Code
-- 3. Move all modules to /usr/lib/prosody/modules
-- 4. Move the mod_smacks module to mod_smacks2 and copy it to mod_smacks3
-- 5. Move the files in mod_smacks* to match the new names
-- 6. In mod_smacks3/mod_smacks3.lua s/urn:xmpp:sm:2/urn:xmpp:sm:3/g
-- 7. Set the Prosody configuration to:
admins = { "ADMIN@HOST" }
daemonize = true
@rektide
rektide / index.html
Last active August 23, 2022 18:46
Unique-ify: In Place or At Finish (http://jsbench.github.io/#bdd6c20c07e440f32d567c59ad4f5e9a) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Unique-ify: In Place or At Finish</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@WebReflection
WebReflection / Object.extra.js
Created August 16, 2012 20:42
Object.getPropertyDescriptor and Object.getPropertyNames
!function(Object, getPropertyDescriptor, getPropertyNames){
// (C) WebReflection - Mit Style License
if (!(getPropertyDescriptor in Object)) {
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
Object[getPropertyDescriptor] = function getPropertyDescriptor(o, name) {
var proto = o, descriptor;
while (proto && !(
descriptor = getOwnPropertyDescriptor(proto, name))
) proto = proto.__proto__;
return descriptor;