Skip to content

Instantly share code, notes, and snippets.

View shadeglare's full-sized avatar
👨‍💻
Pressing keys

Max Koverdyaev shadeglare

👨‍💻
Pressing keys
View GitHub Profile
function takeWhile<T>(xs: T[], callback: (x: T, i: number) => boolean): T[] {
let acc: T[] = [];
xs.some((x, i) => {
if (callback(x, i)) {
acc.push(x);
return false;
} else {
return true;
}
});
export module Singleton {
export function create<T>(creator: () => T) {
let instance: T = null;
return {
get Instance() {
if (Check.isNullOrUndefined(instance)) {
instance = creator();
}
return instance;
}
export module Check {
export function isNull(obj: any) {
return obj === null;
}
export function isUndefined(obj: any) {
return obj === void 0;
}
export function isNullOrUndefined(obj: any) {
return isNull(obj) || isUndefined(obj);
}
const GenderRadio = React.createClass({
props: {
onChange: React.PropTypes.func.isRequired,
checkedIndex: React.PropTypes.number.isRequired
},
getInitialState: function () {
return {
items: [
{ content: (<i className="icon-male"></i>) },
{ content: (<i className="icon-female"></i>) }
/// <reference path="./../typings/tsd.d.ts"/>
/// <reference path="./../node_modules/rx/ts/rx.all.d.ts"/>
import * as Rx from "rx";
import * as Bacon from "baconjs";
let rxstream = new Rx.Subject<string>();
let rxdispatcher = rxstream.do(_ => console.log("rxdo"));
rxdispatcher.subscribe(console.log);
var Frame = Frame || {};
(function($, _, Backbone, Frame) {
var renderTemplate = function(template) {
var templateHtml = template.html();
return _.template(templateHtml, {});
};
var renderTemplateWithModel = function(template, model) {
#if UNITY_STANDALONE_WIN
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using SQLite;
using System;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
namespace Apartama.Network
@shadeglare
shadeglare / render_orders_insert.sql
Last active August 29, 2015 14:07
render_orders
CREATE OR REPLACE FUNCTION render_orders_insert(
_skeleton_id UUID,
_layer_type_id UUID,
_previous_layer_type_id UUID,
_next_layer_type_id UUID)
RETURNS SETOF render_orders AS $$
DECLARE
current_render_order render_orders%ROWTYPE;
next_render_order render_orders%ROWTYPE;
previous_render_order render_orders%ROWTYPE;
module Data {
export interface IMultiKey {
[name: string]: string;
}
export class MultiKeyDictionary<TValue> {
private keyNames: string[];
private linkedItems: {};