Skip to content

Instantly share code, notes, and snippets.

@RobinMalfait
RobinMalfait / colors.cpp
Created Dec 9, 2013
Linux and Mac awesome colors in command line!
View colors.cpp
#include <iterator>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <regex>
/**
* Use namespace std
*/
@RobinMalfait
RobinMalfait / fa-icons.json
Created Apr 7, 2016 — forked from james2doyle/fa-icons.json
A big list (JSON object) of the font awesome icons as of 4.5.0
View fa-icons.json
{
"fa-500px": "500px",
"fa-adjust": "Adjust",
"fa-adn": "Adn",
"fa-align-center": "Align Center",
"fa-align-justify": "Align Justify",
"fa-align-left": "Align Left",
"fa-align-right": "Align Right",
"fa-amazon": "Amazon",
"fa-ambulance": "Ambulance",
@RobinMalfait
RobinMalfait / FontAwesome.json
Created Jun 25, 2014
Font Awesome Json List
View FontAwesome.json
{
"icons": [
{
"name": "Glass",
"id": "glass",
"unicode": "f000",
"created": 1,
"categories": [
"Web Application Icons"
]
@RobinMalfait
RobinMalfait / reset.css
Created Mar 20, 2013
CSS: Eric Meyer's reset
View reset.css
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
View reducer_magic.js
// Switch
const applicationReducer = (state, action) => {
switch (action.type) {
case "FETCH_PACKAGES/START":
case "FETCH_DEPENDENCIES/START":
return {
...state,
fetch_count: state.fetch_count + 1
};
View bigtest.js
it("should create new state when an action is namespaced", async () => {
// Types
const ACCUMULATOR = "ACCUMULATOR";
const ADD = "ADD";
const SUBTRACT = "SUBTRACT";
const MULTIPLY = "MULTIPLY";
// Action creators
function add(value) {
return createAction(namespace(ACCUMULATOR, ADD), value);
@RobinMalfait
RobinMalfait / benefits.md
Last active Nov 16, 2017
Brilliant or bananas: deterministic classNames
View benefits.md
  1. Determenistic classNames
  2. No context switching, the styles are in the same file as the component
  3. Allows for easy deletability (if that's a word), in pure CSS files you can have the problem that you don't (always) know if you can uberhaupt delete the css or not
  4. We still allow for nested styles like:
import { Button } from './Button';
const Accordion = styled.div`
  // We don't need to know which class `.Button` uses, in pure css we _do_ need to know which one
  ${Button} {
View Example.js
const output = {
_: ["a", "b"],
foo: "bar",
baz: true
};
const sgray = ({ _, ...input }) =>
[
..._,
...Object.keys(input).reduce((acc, key) => {
@RobinMalfait
RobinMalfait / Switch.js
Created Nov 15, 2017
classNames util example
View Switch.js
const classNames = (...classes) => classes.filter(Boolean).join(' ');
// No need to default to an empty string as className
function Switch({on, className, ...props}) {
return (
<div className="toggle">
<input
className="toggle-input"
type="checkbox"
/>
View y-combinator.js
/**
* The Y-Combinator
*/
const y = fn => (f => f(f))(f => fn(x => f(f)(x)));
const factorial = y(fac => n => {
return n < 2 ? 1 : n * fac(n - 1);
});
const fibonacci = y(fib => n => {