Skip to content

Instantly share code, notes, and snippets.

View tclain's full-sized avatar

Timothée Clain tclain

View GitHub Profile
fourseven:scss
alanning:roles
accounts-base
accounts-password
aldeed:simple-schemas
dburles:collection-helpers
matb33:collection-hooks
momentjs:moment

Pattern matching

import scala.util.Random

val x: Int = Random.nextInt(10)

x match { case 0 => "zero" case 1 => "one" case 2 => "two"

@tclain
tclain / styled-components-utils.js
Last active May 11, 2018 22:05
styled-components utils
import styled, { css } from 'styled-components';
import at from 'lodash.at';
export const Blue = css`
border-bottom-color: blue;
`
export const Red = css`
border-top-color: red;
@tclain
tclain / css-string-theme.js
Created May 11, 2018 22:04
css string to styled components theme
import flow from 'lodash.flow';
import set from 'lodash.set';
export const cssString = `
:root {
--root: #a;
--sub-theme__variable: #a;
--sub-theme__variable2: #a1;
--sub-theme__variable3__a2: #cecea2;
--sub-theme__variable3__a3: #cecea3;
@tclain
tclain / simple-pattern-match-array-based.js
Created May 22, 2018 15:11
attempt to implement pattern match
import { strictEqual } from '../utils/equality';
import isFunction from 'lodash/isFunction';
/**
* simple value mapper for javascript using strict equality
*
* spec is an object that associate enums like (strings) to arbitrary value / function
* for instance:
*
* const spec = {
@tclain
tclain / view.js
Created June 20, 2018 17:06
simplest view layer in javascript ever (with jquery)
import $ from 'jquery';
const view = ({
template,
state,
el,
} = {}) => {
let state = {...state};
const render = () => {
const interpolated = template(state);
cd ~
SUBLIME_FOLDER="Library/Application Support/Sublime Text 3/Installed Packages"
curl -L https://github.com/emmetio/pyv8-binaries/raw/master/pyv8-osx-p3.zip > v8.zip
mkdir -p $SUBLIME_FOLDER/PyV8
cd $SUBLIME_FOLDER/PyV8
unzip $HOME/v8.zip
<!-- your html code here !-->
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=PT+Sans|Roboto+Slab" rel="stylesheet">
<title>TESTING!!</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

You can quickly get started with Bootstrap with nothing do download using the following template:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
@tclain
tclain / sample.tagged-templates.1.js
Last active May 7, 2019 17:16
samples-tagged-templates
const greet = (name) => `hello ${name}`
greet('timothee') // hello timothee