Skip to content

Instantly share code, notes, and snippets.

Jason O'Neil jasononeil

Block or report user

Report or block jasononeil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jasononeil
jasononeil / zendesk-wysiwyg-styles.css
Created Aug 18, 2017
Styles needed for Zendesk wysiwyg content
View zendesk-wysiwyg-styles.css
.wysiwyg-color-black {
color: #000; }
.wysiwyg-color-black70 {
color: #4d4d4d; }
.wysiwyg-color-black60 {
color: #666666; }
.wysiwyg-color-black50 {
color: gray; }
.wysiwyg-color-black40 {
color: #999999; }
@jasononeil
jasononeil / WebpackLoaderUtil.hx
Last active Jun 5, 2017
A webpack loader that compiles (and watches) a hxml file, including the resulting JS in the webpack bundle.
View WebpackLoaderUtil.hx
import haxe.macro.Context;
import haxe.macro.Type;
import haxe.macro.Expr;
import sys.io.File;
class WebpackLoaderUtil {
public static function outputJson(outputFile:String) {
Context.onGenerate(function (types:Array<Type>) {
var allFilesUsed = [];
for (type in types) {
@jasononeil
jasononeil / angularInjectionMiddleware.js
Last active Dec 12, 2018
Using angular dependency injection with react, redux, and redux-thunk
View angularInjectionMiddleware.js
var thunkDispatcherRef = {
dispatch: function () {}
}
/**
* The angular injection middleware allows our redux actions to return functions.
*
* The function will be executed with regular angular dependency injection, allowing
* you to use angular services in Redux actions.
*
@jasononeil
jasononeil / metrics.txt
Created Nov 14, 2016
List of all Sitespeed 4.0 metrics. I couldn't find this list anywhere, and it took me a while to figure out how to generate the file using grunt-sitespeedio (for future reference: set `sitespeedio.default.options.metrics.list=true`). I figure pasting this here will help some other poor souls thanks to the SEO goodness.
View metrics.txt
browsertime.pageSummary.browserScripts.0.pageinfo.documentHeight
browsertime.pageSummary.browserScripts.0.pageinfo.documentWidth
browsertime.pageSummary.browserScripts.0.pageinfo.responsive
browsertime.pageSummary.browserScripts.0.timings.firstPaint
browsertime.pageSummary.browserScripts.0.timings.fullyLoaded
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.connectEnd
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.connectStart
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.domComplete
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.domContentLoadedEventEnd
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.domContentLoadedEventStart
@jasononeil
jasononeil / ReflectionCost.hx
Created Jun 12, 2016
Demonstrate how much extra code reflection (Reflect.* and Type.*) generate in Haxe code
View ReflectionCost.hx
class ReflectionCost {
public static function main() {
var obj = new ReflectionCost();
#if reflect
Reflect.setField( obj, "name", "Jason" );
Reflect.callMethod( obj, Reflect.field(obj, "printName"), [] );
Type.getInstanceFields( Type.getClass(obj) );
#else
obj.name = "Jason";
obj.printName();
@jasononeil
jasononeil / JS Callback to Future
Last active Nov 10, 2015 — forked from kevinresol/ JS Callback to Future
Convert js-style callback to Future, with macro
View JS Callback to Future
Convert js-style callback to Future, with macro
@jasononeil
jasononeil / ObjectInit.hx
Created Dec 2, 2014
Object initialisations syntax sugar
View ObjectInit.hx
import haxe.macro.Expr;
import haxe.macro.Context;
using haxe.macro.ExprTools;
class ObjectInit {
macro public static function init( expr:Expr, varsToSet:ExprOf<Dynamic<Dynamic>> ) {
var lines:Array<Expr> = [];
lines.push( macro var __obj_init_tmp = $expr );
switch varsToSet.expr {
case EObjectDecl(fields):
@jasononeil
jasononeil / Metric.hx
Last active Nov 10, 2016
Demonstration of using Haxe abstracts to take care of explicit conversions between different units of measurement, with no performance overhead.
View Metric.hx
class Metric {
static function main() {
var coinRadius:Millimeters = 12;
var myHeight:Centimeters = 180;
var raceLength:Meters = 200;
var commuteDistance:Kilometers = 23;
diff( coinRadius, myHeight ); // 1.788 meters
diff( raceLength, commuteDistance ); // 22800 meters
sum( commuteDistance, coinRadius ); // 23000.012 meters
@jasononeil
jasononeil / Http.hx
Created Mar 5, 2014
Workaround for Hxssl being broken for Http requests. Drop these 4 files into a package called "haxe", and you can use this as a drop-in workaround for HxSSL breaking regular HTTP port 80 requests
View Http.hx
package haxe;
@:access( haxe.Https )
@:access( haxe.Http80 )
class Http {
public var h:IHttp;
public var url(get, set) : String;
function get_url() return h.url;
@jasononeil
jasononeil / MethodTyper.hx
Created Feb 19, 2014
Method used in a macro to figure out the return type of a member method. Uses tink_macro
View MethodTyper.hx
/**
Figure out return type of function.
Will first to check if it is explicitly defined.
If not, it attempts to set the function up as a local function expression (EFunction), and then use `Context.typeof( fnExpr )` to evaluate the type.
Will generate a compiler error if member was not a method or method type could not be determined.
**/
static function figureOutReturnTypeOfMemberMethod( member:Member ) {
switch member.getFunction() {
You can’t perform that action at this time.