Skip to content

Instantly share code, notes, and snippets.

Cameron Knight ckknight

View GitHub Profile
View native.re
let to_js_boolean b => if b { Js.true_ } else { Js.false_ };
let optionMap fn opt_value => switch opt_value {
| None => None
| Some value => Some (fn value)
};
module View = {
external view : ReactRe.reactClass = "View" [@@bs.module "react-native"];
let createElement
accessible::(accessible:option bool)=?
View CssVariablesProvider.js
import { Component, PropTypes } from 'react';
function toCssKey(key) {
return `--${key}`;
}
export default class CssVariablesProvider extends Component {
static propTypes = {
variables: PropTypes.objectOf(PropTypes.string).isRequired,
children: PropTypes.element.isRequired,
View rx.flow.js
declare module "rx" {
declare interface IPromise<T> {
then<R>(
onFulfilled: (
value: T
) => IPromise<R>,
onRejected: (
reason: any
) => IPromise<R>
): IPromise<R>;
View ImmEuler.js
import Immutable from 'immutable';
const { Record } = Immutable;
declare class ImmEulerRecordClass extends Record {
x: number;
y: number;
z: number;
order: string;
}
View CustomError.js
// replace `CustomError` with the name of your error
// replace `ParentError` with the superclass, even if it is `Error` or another native error.
// other arguments besides `message` can be added, but at least `message` should exist.
var CustomError = (function (ParentError) {
function CustomError(message) {
var self = this instanceof CustomError ? this : Object.create(CustomError.prototype);
var err = ParentError.call(self, message);
self.message = message;
if (typeof Error.captureStackTrace === 'function') {
View maybe_fly.js
// such new game in Flappy Doge
// http://www.dogetek.co/game/
// plz developer tools in chrome
// much paste in console
// move mouse expert
(function () {
var pos = null;
$(window).mousemove(function (e) {
View inhouse.js
(function(){
var oldPrint = window.print;
var slice = Array.prototype.slice;
window.print = function () {
if (typeof window.onbeforeprint === "function") {
window.onbeforeprint.apply(this, slice.call(arguments));
}
oldPrint.apply(this, slice.call(arguments));
if (typeof window.onafterprint === "function") {
@ckknight
ckknight / tmp-cov.js
Created Jun 19, 2013
GorillaScript coverage example
View tmp-cov.js
try {
if (typeof top === "object" && top !== null && typeof top.opener === "object" && top.opener !== null && !top.opener._$jscoverage) {
top.opener._$jscoverage = {};
}
} catch (e) {}
try {
if (typeof top === "object" && top !== null) {
try {
if (typeof top.opener === "object" && top.opener !== null && top.opener._$jscoverage) {
top._$jscoverage = top.opener._$jscoverage;
View chunk.c.js
function chunk(array, length) {
var chunked = [];
for (var i = 0, len = array.length; i < len; i += length) {
chunked.push(array.slice(i, i + length));
}
return chunked;
};
View Range.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ckknight.Collections
{
/// <summary>
/// Represents an finite, immutable range of Int32s that may have a non-1 step and may or may not be inclusive.
You can’t perform that action at this time.