Skip to content

Instantly share code, notes, and snippets.

View sloria's full-sized avatar

Steven Loria sloria

View GitHub Profile
var MyComponent = Factory({
willMount: function(element, context) {
console.log('component mounted', element.tagName);
};
willUnmount: function(element, context) {
console.log('component unmount', element.tagName);
};
view: function() {
@gilbert
gilbert / component-sugar.js
Last active August 29, 2015 14:17
Mithril Component Sugar
m.callableComponent = function (componentObj) {
var componentFn = function (props, content) {
return m.component(componentFn, props, content)
}
if (componentObj) {
for (var prop in componentObj) {
componentFn[prop] = componentObj
}
}
return componentFn
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@jmcarp
jmcarp / marshmodel.py
Last active March 5, 2018 01:45
marshmallow-models
import six
import inflection
import marshmallow as ma
class Model(object):
def __init__(self, **kwargs):
self._schema = self.Schema()
self.load(**kwargs)

Most downloaded projects

SELECT
  file.project,
  COUNT(*) as total_downloads,
FROM
  TABLE_DATE_RANGE(
    [the-psf:pypi.downloads],
    TIMESTAMP("20160114"),
anonymous
anonymous / dontforget.sh
Created August 5, 2016 11:06
Quick reminders from Terminal (bash) - Linux version
#!/usr/bin/env bash
# dontforget
# Description: A stupid script for short term reminders in bash
# Requires: espeak, mpg123, notify-send, ogg123 (vorbis-tools)
# Source: http://brettterpstra.com/2016/01/22/quick-reminders-from-terminal
# Usage:
#
# Arguments just need to contain a number and a bunch of words.
#
# The number can be anywhere in the arguments, but there shouldn't
@QinMing
QinMing / .zshrc
Last active March 10, 2024 22:17
.zshrc (lazy loading shell functions)
# Copyright (c) 2016-2018 Ming Qin (覃明) <https://github.com/QinMing>
# Open source under MIT LICENSE.
lazy_load() {
# Act as a stub to another shell function/command. When first run, it will load the actual function/command then execute it.
# E.g. This made my zsh load 0.8 seconds faster by loading `nvm` when "nvm", "npm" or "node" is used for the first time
# $1: space separated list of alias to release after the first load
# $2: file to source
# $3: name of the command to run after it's loaded
# $4+: argv to be passed to $3
@staltz
staltz / music.md
Last active September 29, 2023 15:42
coding music

Not for everyone. Each programmer has their own appreciation of what is good coding music.

For when I need to think deep, debug something, or design

(From most influential to least)

@geoffreydhuyvetters
geoffreydhuyvetters / react_fiber.md
Last active January 13, 2023 06:49
What is React Fiber? And how can I try it out today?
@rkrzr
rkrzr / auto_tags.py
Last active April 10, 2024 11:14
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin: