Skip to content

Instantly share code, notes, and snippets.

View benatkin's full-sized avatar

Benjamin Atkin benatkin

View GitHub Profile
const App = () => {
const points = symmetricalCurvePoints({
controlX: 10,
endpointX: 35,
endpointDistance: 15,
controlDistance: 35
})
return (
<div>
<svg
const symmetricalCurvePoints = ({ controlX, endpointX, endpointDistance, controlDistance}) => (
[
[endpointX, 50 - endpointDistance / 2],
[controlX, 50 - controlDistance / 2],
[controlX, 50 + controlDistance / 2],
[endpointX, 50 + endpointDistance / 2]
]
)
const Guide = ({ start, end }) => {
return [
<circle fill="gray" opacity={0.5} cx={start[0]} cy={start[1]} r={1} />,
<path
stroke="gray"
strokeWidth="1"
strokeOpacity={0.5}
fill="transparent"
d={line(start, end)}
/>,
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 January 30, 2018 08:09
XML-as-JSON format inspired by Azure templates, jsx, and WordPress shortcodes
{
"[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 August 10, 2017 00:56
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
// sass scoping
body {
$wow: url(doge.jpg);
background-image: $wow;
}
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 August 29, 2015 14:08
node repl tricks
// 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 August 29, 2015 14:06
rspec: moving from expect to should with vim regexes
s/expect(\([^)]*\)).to /\1.should /
s/eq(\([^)]\+\))/== \1/
s/JSON.parse.*)$/\0.with_indifferent_access/
s/\['\([^']\+\)'\]/[:\1]/g
@benatkin
benatkin / chipotle.swift
Last active August 29, 2015 14:02
lolz
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 {