Skip to content

Instantly share code, notes, and snippets.

Thomas Ingram ravinggenius

Block or report user

Report or block ravinggenius

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
View esm-dual-mode-package.json
{
"name": "dual-cjs-mjs-package",
"version": "1.0.0",
"description": "A package that can be both imported as esm and as cjs",
"main": "entry",
"scripts": {
"build": "babel *.mjs **/*.mjs --out-dir ."
},
"devDependencies": {
"babel-cli": "^6.26.0",
@ravinggenius
ravinggenius / resize.sh
Last active Sep 6, 2017
Batch resize images with ImageMagick
View resize.sh
# place this script in whatever directory you have your albums in
# each album is expected to have an `original` sub-directory where the full-size images actually are
# resized images will be placed in a sibling directory next to `original`
# USAGE
# $ ./resize.sh "2017-09-04 Some Album Name" 1600
# rename arguments
ALBUM=$1 # the name of the directory containing the album (may contain spaces, which is why everything is quoted below)
SIZE=$2 # used to size a bounding box into which images will be resized (aspect ratio will be preserved)
View 500px.js
// node_modules/react-icons/lib/fa/500px.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
View dragon.js
var slaying = true;
// A bit of new math magic to calculate the odds
// of hitting the dragon. We'll cover this soon!
var youHit;
var damageThisRound;
var totalDamage = 0;
do {
youHit = Math.floor(Math.random() * 2);
@ravinggenius
ravinggenius / README.md
Last active Aug 10, 2016
Exploration of allowed mutations in Rip
View README.md

Mutations to the currently-initializing object will be allowed in Rip.

Notes

  • Methods defined at the class level are typically written as a simple reference assignment.
  • @ inside a class refers to the class' prototype property. Properties defined on this object become instance methods.
  • @ inside a method refers to the method's receiver. (self refers to the method itself.)
View pattern.rb
require 'parslet'
module Rip::Parser::Atoms
class Pattern < Parslet::Atoms::Base
attr_reader :pattern
def initialize(pattern)
super()
@pattern = pattern
end
View README.md
@ravinggenius
ravinggenius / list.rip
Last active Oct 6, 2016
System.List.flatten
View list.rip
System.List = class<T> {
flatten = => {
-> (list<System.List>) {
switch (list.count) {
case (0) { list }
case (1) { [ self(list.head) ] }
else { [ ...self(list.head), ...self(list.tail) ] }
}
}
-> (object<System.Object>) { object }
@ravinggenius
ravinggenius / debug.rb
Created Jan 22, 2015
debug methods for rip
View debug.rb
def self.debug(indent, label, context: nil, stack: nil)
body = if context && stack
[
"#{indent * 2} context",
*context_chain(indent * 4, context),
"#{indent * 2} stack",
*call_stack(indent * 4, stack)
]
elsif context
[
You can’t perform that action at this time.