Skip to content

Instantly share code, notes, and snippets.

View icholy's full-sized avatar
💥
breaking things

Ilia Choly icholy

💥
breaking things
View GitHub Profile
module Constraints {
export interface Connector {
setValue(v: number, id?: number): void;
getValue(): number;
hasValue(): boolean;
clearValue(): void;
connect(o: Operation): void;
interface Point {
x: number;
y: number;
}
type Path = Point[];
class PathFinder {
function quicksort(A: number[]): number[] {
let stack = [{ lo: 0, hi: A.length - 1 }];
while (stack.length > 0) {
let { lo, hi } = stack.pop();
if (lo >= hi) {
continue;
/**
* angular-bootstrap-switch
* @version v0.4.1 - 2015-06-15
* @author Francesco Pontillo (francescopontillo@gmail.com)
* @link https://github.com/frapontillo/angular-bootstrap-switch
* @license Apache License 2.0(http://www.apache.org/licenses/LICENSE-2.0.html)
**/
!function(){"use strict";angular.module("frapontillo.bootstrap-switch",[]),angular.module("frapontillo.bootstrap-switch").directive("bsSwitch",["$parse","$timeout",function(a,b){return{restrict:"A",require:"ngModel",link:function(c,d,e,f){var g=!1,h=function(){if("radio"===e.type)return e.value||a(e.ngValue)(c)||!0;var b=a(e.ngTrueValue)(c);return angular.isUndefined(b)&&(b=!0),b},i=function(a){return c.$eval(a)===!0},j=function(a){return a===!0||"true"===a||!a},k=function(a){return a?a:void 0},l=function(a){var b={switchRadioOff:j,switchActive:function(a){return!j(a)},switchAnimate:j,switchLabel:function(a){return a?a:"&nbsp;"},switchIcon:function(a){return a?"<span class='"+a+"'></span>":void 0},switchWrapper:function(a){return a||"wrappe

I've been trying to find an elegant way of dealing with events in TypeScript/AngularJS recently. If you're not farmiliar with Angular, that's ok, this is a pretty common pattern.

Here I have a controller that registers an event listener:

function MyController($rootScope) {
  $rootScope.$on('event1', () => {
    console.log('event 1 occured');
  });
class ListenerGroup {
/**
* Unbinding functions are placed in this array Unbind functions are placed in this array.
*/
private _unbind = [];
/**
* A helper class for managing groups of listeners
* on a specific scope.
package main
import (
"bytes"
"strconv"
)
type Buffer struct {
bytes.Buffer
}
#include "http_core.h"
#include "http_request.h"
static int auth_dummy_handler(request_rec *r)
{
return HTTP_UNAUTHORIZED;
}
static void register_hooks(apr_pool_t *pool)
{
declare module flatbuffers {
/**
* @typedef {number}
*/
export type Offset = number;
/**
* @typedef {{
* bb: flatbuffers.ByteBuffer,
  • The gain is how much of the new measurement to use.
  • The measurement error is constant and depends on the source.
interface Estimate {
  value: number;
  error: number;
}