Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Atkin benatkin

View GitHub Profile
View svg-path-functions.js
const curve = (start, control1, control2, end) => {
return [
"M",
start.join(" "),
"C",
control1.join(" "),
control2.join(" "),
end.join(" ")
].join(" ");
}
@benatkin
benatkin / html5-logo.json
Last active Jan 30, 2018
XML-as-JSON format inspired by Azure templates, jsx, and WordPress shortcodes
View html5-logo.json
{
"[svg xmlns=http://www.w3.org/2000/svg viewBox='0 0 512 512']": [
{"[title]": "HTML5 Logo"},
"[polygon fill='#E44D26' points='107.644,470.877 74.633,100.62 437.367,100.62 404.321,470.819 255.778,512']",
"[polygon fill='#F16529' points='256,480.523 376.03,447.246 404.27,130.894 256,130.894']",
"[polygon fill='#EBEBEB' points='256,268.217 195.91,268.217 191.76,221.716 256,221.716 256,176.305 255.843,176.305 142.132,176.305 143.219,188.488 154.38,313.627 256,313.627']",
"[polygon fill='#EBEBEB' points='256,386.153 255.801,386.206 205.227,372.55 201.994,336.333 177.419,336.333 156.409,336.333 162.771,407.634 255.791,433.457 256,433.399']",
"[path d='M108.382,0h23.077v22.8h21.11V0h23.078v69.044H152.57v-23.12h-21.11v23.12h-23.077V0z']",
"[path d='M205.994,22.896h-20.316V0h63.72v22.896h-20.325v46.148h-23.078V22.896z']",
"[path d='M259.511,0h24.063l14.802,24.26L313.163,0h24.072v69.044h-22.982V34.822l-15.877,24.549h-0.397l-15.888-24.549v34.222h-22.58V0z']",
@benatkin
benatkin / SassMeister-input.scss
Created Aug 10, 2017
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
// sass scoping
body {
$wow: url(doge.jpg);
background-image: $wow;
}
View es6-fizzbuzz.js
class Buzzer {
constructor(message, factor) {
this.factor = factor;
this.message = message;
}
buzz(number) {
if (number % this.factor == 0) {
console.log(this.message);
return true;
@benatkin
benatkin / repl.js
Last active Aug 29, 2015
node repl tricks
View repl.js
// add ;0 to suppress long results, like a process or a mongoose connection
process;0
// capture information from async calls. doesn't work on calls that use the arity. make a custom call for those.
var results = [], capture = function() { results.unshift([].slice.call(arguments)) }
// handle uncaught exceptions so a mistake in the console doesn't bounce you out of your session
process.on('uncaughtException', function(err) { console.log('***uncaught***', err); });0
@benatkin
benatkin / expect-to-should.txt
Last active Aug 29, 2015
rspec: moving from expect to should with vim regexes
View expect-to-should.txt
s/expect(\([^)]*\)).to /\1.should /
s/eq(\([^)]\+\))/== \1/
s/JSON.parse.*)$/\0.with_indifferent_access/
s/\['\([^']\+\)'\]/[:\1]/g
View chipotle.swift
enum EntreeType : Int {
case Burrito, BurritoBowl, CrispyTacos, SoftTacos, Salad
}
enum Filling : Int {
case Chicken, Steak, Barbacoa, Carnitas, Sofritas, Veggie
var price : Int {
get {
switch self {
case .Chicken, .Sofritas, .Veggie {
@benatkin
benatkin / lgpl.md
Last active Aug 29, 2015
Why you shouldn't use the Lesser GPL for your library
View lgpl.md

Many who start open source projects, especially those for companies, think that they can get around the obstacles to adoption of the GPL just by using the LGPL. While it removes some of the obstacles, it leaves others:

  • Complexity: The GPL and LGPL are both long and depend on definitions of concepts (such as Application, Library, and Combined Work) which are unclear in practice.
  • Reuse: The LGPL restricts taking a small part of code, modifying it, and publishing it with a library in a different license. This results in people who wish to use a different license having to start from scratch, or make the code boundaries clear, where it often doesn't make sense to do so. I see this happening with rich text editors where the major libraries are under the GPL or LGPL.

Instead of dual-licensing, do what many companies have and make the leap to the MIT or Apache2 licenses. Ghost and Meteor have.

@benatkin
benatkin / gen-rm-script
Last active Aug 29, 2015
script for removing some files
View gen-rm-script
#!/usr/bin/env node
var fs = require('fs')
var dirs = fs.readdirSync('.')
dirs.forEach(function(dir) {
console.log('#rm -r ' + '"' + dir.replace('"', '"\'"\'"') + '"')
})
@benatkin
benatkin / index.js
Created May 8, 2014
requirebin sketch
View index.js
var React = require('react-component')
var h = React.DOM
var _ = null;
var crete = require('crete')
var insertCss = require('insert-css')
var rulesets = [
{sel: '*', 'font-family': 'Helvetica, Arial, sans-serif'},
{sel: 'body > div', padding: '10px'},
{sel: 'ul, li',