Skip to content

Instantly share code, notes, and snippets.

@andrejewski
andrejewski / travis-firefix.js
Last active July 27, 2017 01:10
Super mod: update Travis Firefox version
var fs = require('fs')
var path = require('path')
module.exports = {
getOptions: function () {
return [{
name: 'version',
type: 'input',
default: '51.0',
message: 'New Firefox version:'
@andrejewski
andrejewski / refactor-example.js
Created June 27, 2017 03:09
Refactor example of donejs/cli
// OLD
// Returns a .then-able function that installs a single module
// if it is not available in the current path
var installIfMissing = exports.installIfMissing = function(root, module, range) {
var location = module ? path.join(root, module) : root;
if(!module) {
module = root;
}

can-dom-events

This is the DOM events API.

The package modules are:

  • can-dom-events which replaces can-util/dom/events
  • can-dom-events/event/make-custom for standardizing custom events
  • can-dom-events/event/make-native for standardizing native events
  • can-dom-events/event/make-compat for compatibility with can-util/dom/events
@andrejewski
andrejewski / bye-david.js
Last active May 5, 2017 19:04
landscaper codeshift test
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.Literal)
.forEach(path => {
var raw = path.node.raw.toLowerCase()
if (raw === '"david"' || raw === "'david'") {
j(path).replaceWith(
j.literal("😿😢👎")
@andrejewski
andrejewski / text-file.js
Created May 3, 2017 17:08
Landscaper test mods
var fs = require('fs')
var path = require('path')
module.exports = {
getOptions: function () {
return [{
name: 'content',
type: 'input',
default: 'Some text I made',
message: 'Text to write'
@andrejewski
andrejewski / goog.html5history+query.js
Last active March 21, 2019 03:10
goog.HTML5History with query params
/*
A fix for HTML5History with query parameters.
Hey, this wasted my time so here is an explanation.
By default, Closure's goog.HTML5History does the stupid
thing of adding query params of the current location to
whatever new path you are navigating to. I did not need
that so here is the fix:
*/
@andrejewski
andrejewski / himalaya-strip-whitespace.js
Last active October 27, 2018 08:53
Strip whitespace from Himalaya output
function removeEmptyNodes (nodes) {
return nodes.filter(node => {
if (node.type === 'element') {
node.children = removeEmptyNodes(node.children);
return true
}
return node.content.length
})
}
@andrejewski
andrejewski / defer.js
Created November 19, 2016 15:32
My quick deferred utility I seem to use everywhere
/*
Defer.js
Usage:
const myDefer = new Defer()
myDefer.then(x => assert.equal(x, 1))
myDefer.resolve(1)
*/
export default class Defer {
# DeCoffeeScript script
if [[ -z "$1" ]] ; then
echo 'decaf error: pass a basename'
exit 1
fi
coffee_file=$1.coffee
js_file=$1.js
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->