Skip to content

Instantly share code, notes, and snippets.

@swayf
swayf / drag_and_drop_helper.js
Created December 18, 2015 23:20 — forked from rcorreia/drag_and_drop_helper.js
drag_and_drop_helper.js
(function( $ ) {
$.fn.simulateDragDrop = function(options) {
return this.each(function() {
new $.simulateDragDrop(this, options);
});
};
$.simulateDragDrop = function(elem, options) {
this.options = options;
this.simulateEvent(elem, options);
};
using WorkerScript;
class MyWorkerScript extends WorkerScript {
public override function onMessage(e){
trace("on message triggered");
postMessage("ola");
}
static function main(){
package amd;
#if macro
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.*;
import haxe.ds.*;
using Lambda;

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables

@swayf
swayf / RegTest.hx
Last active August 29, 2015 14:11 — forked from Lerc/RegTest.hx
import js.html.Uint8Array;
@:build( RegisterMacro.memoryMappedRegister("r0",123) )
class RegTest
{
var ram : Uint8Array;
public function new() {
ram = new Uint8Array(65536);
}
@swayf
swayf / Main.hx
Last active August 29, 2015 14:08 — forked from nadako/Main.hx
import StructHelper.make;
typedef A = {
a:Int,
b:String,
c:Float,
d:Bool,
e:Array<Int>,
f:{
g:Array<Bool>,
@swayf
swayf / Makefile
Last active August 29, 2015 14:07 — forked from mattmccray/Makefile
.PHONY: compile
time=/usr/bin/time
compile: dart typescript coffeescript haxe jsx
dart:
$(time) dart2js -ooutput/dart.js source/simple.dart
typescript:
package ;
import neko.Lib;
import sys.db.Manager;
import sys.db.Object;
import sys.db.Sqlite;
import sys.db.Types.SDate;
import sys.db.Types.SId;
import sys.db.Types.SNull;
import sys.db.Types.SString;
package ;
import neko.Lib;
import sys.db.Manager;
import sys.db.Object;
import sys.db.Sqlite;
import sys.db.Types.SDate;
import sys.db.Types.SId;
import sys.db.Types.SNull;
import sys.db.Types.SString;
@swayf
swayf / Gen.hx
Last active August 29, 2015 14:06 — forked from back2dos/Gen.hx
package ;
import haxe.macro.*;
import haxe.macro.Type;
using haxe.macro.Tools;
private typedef Accessor = {
name: String,
read: Bool,