Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
TheSeamau5 / HackerNewsExample.elm
Last active September 23, 2018 00:24
Hacker news requests example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn)
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --
@TheSeamau5
TheSeamau5 / artistSearchExample.elm
Last active March 10, 2016 15:12
Artist Search Example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Json.Decode as Decode exposing (Decoder, object2, map, string, list, (:=))
import Task exposing (Task, andThen, succeed, fail, onError)
import Signal exposing (Signal, Mailbox, mailbox, message, send)
import String
-------------------------
@msroot
msroot / gist:47df17ccee8f4210cc5d
Created April 2, 2015 02:05
Import YAML translations to I18n::Backend::ActiveRecord::Translation
data = YAML::load(File.open("config/locales/en.yml"))
translations = {}
def process_hash(translations, current_key, hash)
hash.each do |new_key, value|
combined_key = [current_key, new_key].delete_if { |k| k == '' }.join(".")
if value.is_a?(Hash)
process_hash(translations, combined_key, value)
else
translations[combined_key] = value
@alexpchin
alexpchin / restful_routes.md
Last active November 12, 2024 08:50
7 Restful Routes
URL HTTP Verb Action
/photos/ GET index
/photos/new GET new
/photos POST create
/photos/:id GET show
/photos/:id/edit GET edit
/photos/:id PATCH/PUT update
/photos/:id DELETE destroy
@rauchg
rauchg / effective-es6.md
Last active July 11, 2023 09:38
Writing ES6 today, effectively.

Effective transpiling of ES6

After publishing my article on ECMAScript 6, some have reached out to ask how I exactly I make it all work.

I refrained from including these details on the original post because they're subject to immiment obsoletion. These tools are changing and evolving quickly, and some of these instructions are likely to become outdated in the coming months or even weeks.

The main tool

When evaluating the available transpilers, I decided to use 6to5, which has recently been renamed to Babel. I chose it based on:

@sebmarkbage
sebmarkbage / Enhance.js
Last active February 10, 2025 06:23
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@simonewebdesign
simonewebdesign / mmv.sh
Last active August 30, 2018 03:44
mmv: move/copy/append/link multiple files by wildcard patterns
# Create multiple folders
$ mkdir -p source/tags/modules/{dob,grid,radio,set,telephone,text}
# Move multiple files by wildcard pattern
$ mmv "source/tags/modules/*.txt" "source/tags/modules/#1/#1.txt"
# Create multiple files by wildcard pattern (e.g. same name as their folder)
$ cd source/tags/modules
# then...
@bobbygrace
bobbygrace / trello-css-guide.md
Last active December 10, 2024 21:04
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@ericelliott
ericelliott / essential-javascript-links.md
Last active March 22, 2025 17:28
Essential JavaScript Links
@simonewebdesign
simonewebdesign / postgres.sh
Last active May 7, 2021 18:05
Postgres Cheatsheet for Linux and macOS: Login on psql and create a new user role. Also dump and restore.
# Install postgres first (e.g. OS X):
brew install postgres
# After installation... if user not created:
# This is a wrapper around CREATE ROLE, you might not have it.
# BTW, a role is the same as a user.
# A role is an entity that can own database objects and have database privileges;
# a role can be considered a "user", a "group", or both depending on how it is used.
createuser --superuser postgres # -s works as well