Skip to content

Instantly share code, notes, and snippets.

View joenoon's full-sized avatar

Joe Noon joenoon

  • SF Bay Area - San Ramon
View GitHub Profile
@joenoon
joenoon / YapModel.rb
Created January 17, 2014 09:58
Rubymotion wrapper for YapDatabase. Tested on 1.2.2. Makes some assumptions about your objects, currently not abstract enough to be a gem. See the top of the file for some example usage.
# Copyright (c) 2013 Joe Noon (https://github.com/joenoon)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
if defined?(PhusionPassenger)
# Rails.logger is not available at the time of adding the middleware
class PassengerRailsLoggerProxy
def info(*args)
if @logger ||= Rails.logger
@logger.info(*args)
end
end
end
PhusionPassenger.require_passenger_lib 'rack/out_of_band_gc'
@joenoon
joenoon / cbldocs.sh
Last active August 29, 2015 14:23
CLI wrapper to simplify outputting a doc or all docs from a cblite db.
#!/bin/bash
#
# CLI wrapper to simplify outputting a doc or all docs from a cblite db.
#
# The MIT License (MIT)
#
# Copyright (c) 2015, Joe Noon
#
# Creates classes in Obj-C and Java that contain values from
# config.yaml (which can be overridden by ENV).
# Values are obfuscated. (Untested as to how secure this is,
# but the point is to do better than completely plain
# public api keys visible in builds/plists)
# The key value pairs can be accessed from React Native via:
# NativeModules.AppEnv.XYZ
@joenoon
joenoon / MailgunSender.js
Created October 9, 2017 00:59
This is a simple wrapper around mailgun.send that adds easy templating and forces tags to be used.
//
// MailgunSender
// Copyright 2017 Joe Noon <[email protected]>
// MIT License
//
// This is a simple wrapper around mailgun.send that adds easy templating and forces
// tags to be used.
//
// Initialize a MailgunSender with the path to your templates, and instance of mailgun:
//
const LETTERS = 'acdfgilmnoprstuw';
const HASH = 7;
function hash(s) {
let hash = HASH;
for (let i = 0; i < s.length; i++) {
hash = (hash * 23 + LETTERS.indexOf(s[i]));
}
return hash;
}
@joenoon
joenoon / quaternion.js
Created June 15, 2018 04:39 — forked from bellbind/quaternion.js
[javascript]understanding quaternion
//[understanding quaternion]
// - basic vector knowledge
// - quaternion basics
// - quaternion multiply
// - rotation with quaternion
// - slerp
// - convert quaternion to matrix
//[(basic) vector func]
var negate = function (vec) {
@joenoon
joenoon / icon.js
Created June 27, 2018 07:26
SVG icon react class
import React from 'react';
import {View} from 'react-native';
function Icon(props: {size: number, color: string, name: string, style?: any}) {
const SVGIcon = Icon.SVGS[props.name];
if (!SVGIcon) {
throw new Error(`Unknown icon ${props.name}`);
}
const {style, ...rest} = props;
@joenoon
joenoon / flash.ts
Created October 16, 2018 07:16
Flash implementation inspired by Rails (ie. flash[:notice]) for frontend.
import { observable, computed, toJS } from 'mobx';
function defaultData() {
return {
text: null,
dataText: null,
type: null,
};
}
@joenoon
joenoon / jn-mobx-lite.ts
Last active March 25, 2019 08:27
Simplified pattern for using mobx-react-lite with less room for error
import {useComputed, useObservable, useObserver as useObserverInternal} from 'mobx-react-lite';
const HOOKS = {
useComputed,
useObservable,
};
export type MobxReactLiteHooks = typeof HOOKS;
// This is for my convenience, not neccessary for the pattern.
export * from 'mobx';