Skip to content

Instantly share code, notes, and snippets.

View voodooattack's full-sized avatar

Abdullah A. Hassan voodooattack

View GitHub Profile
@voodooattack
voodooattack / fiberify.js
Last active August 29, 2015 14:26
Forcing express.js to use Fibres for ALL REQUESTS.
import Fiber from 'fibers';
// Modify express to always spawn a new fibre if none are active.
export default function (router) {
var oldProcess = router.process_params;
if (oldProcess)
router.process_params = function(...args) {
if (!Fiber.current)
Fiber(oldProcess.bind(router, ...args)).run();
else
oldProcess.apply(router, args);
@voodooattack
voodooattack / app.js
Last active August 29, 2015 14:27
restify: Generate isomorphic Marty.js services for baucis controllers.
Marty.HttpStateSource.removeHook('parseJSON');
Marty.HttpStateSource.addHook({
id: 'CSRF',
priority: 1,
before(req) { req.headers['CSRF-Token'] = /* ... obtain a csrf token from somewhere in your application ... */ }
});
class Application extends Marty.Application {
constructor(options = {}) {
@voodooattack
voodooattack / mingw_install_all.sh
Created December 26, 2011 17:02
MinGW package installer [INSTALLS ALL PACKAGES]
#!/bin/sh
(env sed --version &> /dev/null || (echo -e "GNU sed not found, attempting to install package:\n";\
(exec 3>&1 4>&2; sed_error=$( { mingw-get install msys-sed 2>&4 1>&3; } 2>&1 ); exec 3>&- 4>&-;\
if ($sed_error); then echo "Could not install GNU sed, aborting.."; exit 1; fi))) && sed_ver_str=\
$(env sed --version) && sed_ver=$(echo $sed_ver_str | sed -n 's/.*version \([0-9\.]*\).*/\1/p') &&\
echo "GNU sed is already installed. (version $sed_ver)" && mingw-get update && PACKAGES=$(mingw-get list\
| sed -ne "s/\(^Package\:\)[[:blank:]]\?\([[:alnum:][:punct:]]\+\).*$/\2\\n/p")\ && echo -en \
"\nInstalling packages:\n\n$(echo $PACKAGES | tr ' ' '\n' | sort -d | pr -3 -atT)\n\n" && echo -en\
"Package Count: $(echo $PACKAGES | tr ' ' '\n' | wc -l -- | tr -d '[:space:]' && echo)\n\n" && read\
-p "Press return to install" -s && mingw-get --verbose=2 install $PACKAGES
var startTime = Date.now()
var fs = require('fs')
var Iconv = require('iconv').Iconv
var cluster = require('cluster')
var workers;
if (cluster.isMaster) workers = [1, 2, 3, 4].map(_ => cluster.fork())
if (!cluster.isMaster)
{
import { GraphQLSchema } from 'graphql/type';
import { graphql } from 'graphql';
import { type, query, mutation, field, iface, Schema } from '../src';
class MySchema extends Schema { }
/**
* Declare a basic interface
*/
@voodooattack
voodooattack / README.md
Last active September 24, 2017 21:29
A server-side session API for Vulcan.js.

webtoken-session

A server-side session API for Vulcan.js.

This meteor package provides a session object on the Vulcan.js render context.

The session is stored inside a jsonwebtoken cookie on the client and is automatically saved at the end of each request. (including GraphQL queries)

Particularly useful when used in conjunction with internal-graphql*, which makes GraphQL requests internal to the server process.

@voodooattack
voodooattack / README.md
Last active October 2, 2017 01:11
Make Vulcan.js self-contained.

Internal GraphQL for Vulcan.js

To make a GraphQL query on a Vulcan.js server, your server has to connect to itself via a new HTTP connection every time it receives a request.

This package makes it so that Vulcan’s GraphQL queries never leave the process. All GraphQL requests are processed with no overhead.

See also: webtoken-session

@voodooattack
voodooattack / magic.md
Last active September 16, 2018 20:13
Spell specs for the story: The Magineer, you can read it at: https://www.themagineer.com/. The official document is now located at: https://www.themagineer.com/spell-syntax

The Science Of Magic

Forces:

Spatial Manipulation:

  • Manipulate (Attract/Repel/Move) (Velocity Manipulation)
  • Spin (Angular Velocity Manipulation)

Atomic Manipulation:

  • Compress <--> Expand
@voodooattack
voodooattack / when.md
Last active September 17, 2018 21:25
When: A proposition for a new, event-based programming language based on JavaScript.

when - event-based programming

when is an event-based programming language based on JavaScript, with a few key differences.

when is not fully procedural, and execution can flow non-linearly through the source code.

Program state

A program’s state consists of:

@voodooattack
voodooattack / when-ts.ts
Last active September 18, 2018 05:44
when-ts: first draft
import 'reflect-metadata';
export interface MachineState {
}
/**
* An activation condition, takes two arguments and must return true for the associated action to fire.
*/
export type ActivationCond<State extends MachineState> =
(state: Readonly<State>, machine: EventMachine<State>) => boolean;