Skip to content

Instantly share code, notes, and snippets.

View sophistifunk's full-sized avatar

Josh McDonald sophistifunk

  • Expantra
  • Brisbane, Australia
View GitHub Profile
#! /usr/local/bin/node
"use strict";
var wordsPerLine = 4;
var crypto = require("crypto");
var fs = require("fs");
var words = JSON.parse(fs.readFileSync(__dirname + "/words.json").toString("UTF8")).words;
var count = words.length;
@sophistifunk
sophistifunk / arrow binding.js
Created June 8, 2017 07:38
arrow binding.js
class A {
__identify() {
return "Class A"
}
idNotBound() {
return this.__identify()
}
idBound = () => {
class Alpha {
constructor() {
this.a = "red";
this.#b = "green";
}
identify() {
console.log(this.a, this.#b);
}
}
let arr = [10, 11, 12, 13];
console.log(arr.length); // 4
arr.foo = "bar";
console.log(arr.length); // 4
console.log(1 in arr); // true
console.log(arr[10] === undefined); // true
console.log(10 in arr); // false
// Pipeline
export type PipelineInfo = {
pipelineMetadata: any
}
// Stages
export type StageInfo = {
name: string,
uid: string,
pipelineMetadata: any
@sophistifunk
sophistifunk / pre-publish.js
Created June 6, 2016 23:54
Pre-publish POC to block "npm publish" from command line
"use strict";
const npm_config_argv = process.env.npm_config_argv;
if (!npm_config_argv) {
console.error("This script should only be run via npm trigger -- npm_config_argv not found in ENV");
process.exit(1);
}
let isInstall = false;
// Old
var docHead = exports.getHeadElement();
var rootURL = getAttribute(docHead, "data-rooturl");
if (!rootURL) {
throw "Attribute 'data-rooturl' not defined on the document <head> element.";
}
// New
var docHead = exports.getHeadElement();
var rootURL = getAttribute(docHead, "data-rooturl");
//From This:
<Route path={rootRoutePath} component={OrganisationPipelines}>
<IndexRoute component={Pipelines}/>
<Route path=":pipeline/branches" component={MultiBranch}/>
<Route path=":pipeline/activity" component={Activity}/>
<Route path=":pipeline/pr" component={PullRequests}/>
</Route>
//To this:
import React, {Component} from 'react';
function Alpha(props) {
console.log("Alpha props.className", props.className);
return <strong className="onStrong">Alpha</strong>;
}
function Bravo(props) {
console.log("Bravo props.className", props.className);
return <Alpha className="san"/>;
// All you needed to do if you wanted codegen:
[Bindable]
public var easyProp:MyClass;
// More explicit version using a named event:
private var _myProp:MyClass;
[Bindable("myPropChange")]
public function get myProp():MyClass
{