Skip to content

Instantly share code, notes, and snippets.

@RobinMalfait
RobinMalfait / colors.cpp
Created December 9, 2013 21:36
Linux and Mac awesome colors in command line!
#include <iterator>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <regex>
/**
* Use namespace std
*/
@RobinMalfait
RobinMalfait / siaf.js
Last active July 7, 2023 12:35
JavaScript: self invoking anonymous function
/**
*
* Self-Invoking Anonymous Function
*
**/
(function(){
})();
@RobinMalfait
RobinMalfait / FontAwesome.json
Created June 25, 2014 20:42
Font Awesome Json List
{
"icons": [
{
"name": "Glass",
"id": "glass",
"unicode": "f000",
"created": 1,
"categories": [
"Web Application Icons"
]
@RobinMalfait
RobinMalfait / fa-icons.json
Created April 7, 2016 09:06 — forked from james2doyle/fa-icons.json
A big list (JSON object) of the font awesome icons as of 4.5.0
{
"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 / reset.css
Created March 20, 2013 18:27
CSS: Eric Meyer's reset
/* 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,
// Switch
const applicationReducer = (state, action) => {
switch (action.type) {
case "FETCH_PACKAGES/START":
case "FETCH_DEPENDENCIES/START":
return {
...state,
fetch_count: state.fetch_count + 1
};
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 November 16, 2017 16:10
Brilliant or bananas: deterministic classNames
  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} {
const output = {
_: ["a", "b"],
foo: "bar",
baz: true
};
const sgray = ({ _, ...input }) =>
[
..._,
...Object.keys(input).reduce((acc, key) => {
@RobinMalfait
RobinMalfait / Switch.js
Created November 15, 2017 09:12
classNames util example
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"
/>