Skip to content

Instantly share code, notes, and snippets.

@jorinvo
jorinvo / js-graphic-designer.js
Last active August 29, 2015 14:10
API Design for js-graphic-designer
// Initialze
var designer = graphicDesigner({
// required:
element: '#container',
// optional:
unit: 'pixel' // `pixel` or `inch` or `mm`
dpi: 300, // only use with inch or mm
width: 500,
height: 500,
scaleFactor: 1,
@jorinvo
jorinvo / long.js
Last active August 29, 2015 14:10
example syntax for declarative aync testing style (answer to http://blog.oozou.com/stateful-context-working-with-multiple-values-in-a-promise-chain/)
describe('following another user', function() {
declare({
// get rid of small functions with partials
firstUser: partial(createUser, 'foo'),
secondUser: partial(createUser, 'bar')
// no need for function introspection with this syntax
// get knows strings describe dependencies and function are async
// getTimeline is a function that accepts a user as arugment now
timeline: partial(get, 'firstUser', getTimeline),
@jorinvo
jorinvo / log_stats.rb
Last active August 29, 2015 14:13
A solution for the Dev Challenge. Analyses a log file.
#!/usr/bin/env ruby
# USAGE:
# Script can be called from the command line with `./log_stats.rb`.
# Optional a log file can be specified: `./log_stats.rb path/to/file.log`.
# This function kicks off the script in case it's called from the command line
def run!
@jorinvo
jorinvo / demo.js
Last active August 29, 2015 14:14
Declare functions in order of importance
var upDown = function(name) {
return up(name) + '-' + down(name)
}
var up = function(s) {
return s.toUpperCase()
}
@jorinvo
jorinvo / factorialWithLambdaCalc.js
Last active August 29, 2015 14:15
JS version of code from Jim Weirichs Talk on Lambda Calculus (https://www.youtube.com/watch?v=FITJMJjASUs)
// Y Combinator
// makes the recursion
(function(improver) {
return (function(gen) { return gen(gen) })(
function(gen) {
return improver(function(v) {
return gen(gen)(v)
})
}
)
@jorinvo
jorinvo / data.json
Last active September 21, 2020 17:30
Test data for little challenge
This file has been truncated, but you can view the full file.
[
{"name":"Keeley Bosco","email":"[email protected]","city":"Lake Gladysberg","mac":"08:fd:0b:cd:77:f7","timestamp":"2015-04-25 13:57:36 +0700","creditcard":"1228-1221-1221-1431"},
{"name":"Rubye Jerde","email":"[email protected]","city":null,"mac":"90:4d:fa:42:63:a2","timestamp":"2015-04-25 09:02:04 +0700","creditcard":"1228-1221-1221-1431"},
{"name":"Miss Darian Breitenberg","email":null,"city":null,"mac":"f9:0e:d3:40:cb:e9","timestamp":"2015-04-25 13:16:03 +0700","creditcard":null},
{"name":"Celine Ankunding","email":"[email protected]","city":null,"mac":"3a:af:c9:0b:5c:08","timestamp":"2015-04-25 14:22:22 +0700","creditcard":"1228-1221-1221-1431"},
{"name":"Dr. Araceli Lang","email":"[email protected]","city":"Yvettemouth","mac":"9e:ea:28:41:2a:50","timestamp":"2015-04-25 21:02:11 +0700","creditcard":"1211-1221-1234-2201"},
{"name":"Esteban Von","email":null,"city":null,"mac":"2d:e4:f0:dd:90:96","timestamp":"2015-04-25 21:47:09 +0700","creditcard":null},
{"name":"Everette Swift","em
@jorinvo
jorinvo / challenge.md
Last active November 19, 2024 02:40
This is a little challenge to find out which tools programmers use to get their everyday tasks done quickly.

You got your hands on some data that was leaked from a social network and you want to help the poor people.

Luckily you know a government service to automatically block a list of credit cards.

The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.

The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:

YYYYMMDD.csv.

name creditcard
Keeley Bosco 1228-1221-1221-1431
Rubye Jerde 1228-1221-1221-1431
Celine Ankunding 1228-1221-1221-1431
Dr. Araceli Lang 1211-1221-1234-2201
Terrell Boyle 1228-1221-1221-1431
Libby Renner 1234-2121-1221-1211
Alessandro Barton 1234-2121-1221-1211
Dr. Art Grimes 1211-1221-1234-2201
Keven Purdy 1211-1221-1234-2201
@jorinvo
jorinvo / bindActions.js
Last active August 29, 2015 14:23
miniflux
export default function bindActions (actions, render, initialState) {
var state = initialState
function update (updatedState) {
state = updatedState
render(state)
}
var boundActions = Object.keys(actions).reduce(function (o, name) {
o[name] = function () {
@jorinvo
jorinvo / package.json
Created November 4, 2015 10:07
Scripts section for a react project
{
"config": {
"port": 3000,
"api_url": "http://localhost:3000/api"
},
"scripts": {
"start": "export NODE_ENV=production; npm run build && npm run server",
"watch": "npm run server:watch & npm run test:watch & wait",
"server": "node server.js",
"server:watch": "nodemon --watch server.js server.js",