Skip to content

Instantly share code, notes, and snippets.

View jkup's full-sized avatar

Jon Kuperman jkup

View GitHub Profile
@jkup
jkup / function.scala
Created October 13, 2016 07:35
Scala Function
def foo() {
println('bar')
}
@jkup
jkup / function.js
Created October 13, 2016 07:34
JavaScript Function
function foo() {
console.log('bar');
}
@jkup
jkup / copyWithinEx2.js
Created October 13, 2016 07:31
copyWithinEx2
[1, 2, 3, 4, 5, 6, 7, 8].copyWithin(0, 3);
// copies the values from index 3 to the end of the array ( 4, 5, 6, 7, 8 )
// plays them in place on the array starting at 0 ( value 1 )
// returns [4, 5, 6, 7, 8, 6, 7, 8]
@jkup
jkup / copyWithinEx1.js
Created October 13, 2016 07:31
copyWithinEx1
[1, 2, 3, 4, 5, 6, 7, 8].copyWithin(0, 3, 5);
// copies the values from index 3 to 5 ( 4, 5 )
// plays them in place on the array starting at 0 ( value 1 )
// returns [4, 5, 3, 4, 5, 6, 7, 8]
@jkup
jkup / copyWithinBasic.js
Created October 13, 2016 07:29
copyWithin
Array.prototype.copyWithin(target, start, end)
@jkup
jkup / example.js
Last active June 11, 2016 06:31
Sometimes it's wild how different my JavaScript looks from a few years ago
'use strict'
import React from 'react'
import { StyleSheet, css } from 'aphrodite'
class ToDoList extends React.Component {
constructor (props) {
super(props)
this.displayName = 'ToDoList'
@jkup
jkup / index.js
Last active April 20, 2016 22:18
JavaScript try-catch
var a, b, c;
try {
b = 'foo';
a = nonExistent;
c = 'bar';
} catch(e) {}
console.log(a, b, c); // 'foo', undefined, undefined
@jkup
jkup / chdir.js
Created March 28, 2016 00:08
Change Directory
#!/usr/bin/env node
const process = require('process')
process.chdir('/foo')
console.log(process.cwd()) // This logs foo
// but then if I run this my terminal doesn't change
@jkup
jkup / index.jsx
Created December 15, 2015 23:47
React Question
<div className={(condition) ? 'grid-item Rejection Rejection--width2' : 'grid-item Rejection'}>
// How can I do this without repeating the grid-item and Rejection classes?
// Something like:
//<div className={"grid-item Rejection" if (condition) { "Rejection--width2" }}>
@jkup
jkup / index.js
Last active October 5, 2015 01:11
JavaScript multiline string regex
var string = "www.one \
www.two \
www.three";
var pattern = /^(www\.)\w+/gm;
console.log(string.match(pattern));