Skip to content

Instantly share code, notes, and snippets.

@forkfork
forkfork / ioredis_example.js
Last active April 13, 2021 17:41
Example of using Redis Streams with Javascript/ioredis
var Redis = require('ioredis');
var redis = new Redis({
host: "nodesydney.wiftycloud.com",
password: "7884b8baaa49fbcb48f17ad2a146"
});
async function main() {
// write an event to stream 'events', setting 'key1' to 'value1'
await redis.sendCommand(
@colinbendell
colinbendell / convert_giphy_gifs.sh
Created December 4, 2017 02:48
Simple mass conversion of GIF to MP4 (h264/h265), WebM (vp8/vp9) and WebP
#!/bin/sh
curl 'https://giphy.com/page/2?next=2017-12-01%2004%3A15%3A01&amp%3Bis=1&is=1&json=true' -o gipyurls.json
jq .[].gifs[].images.original.url gipyurls.json |cut -d / -f 5 | parallel -j 20 --gnu curl https://media2.giphy.com/media/{}/giphy.gif -o {}.gif
parallel -j 20 --gnu "ffmpeg -f gif -i {} {}.h264.mp4" ::: *.gif
parallel -j 20 --gnu "ffmpeg -f gif -i {} -c:v libx265 {}.h265.mp4" ::: *.gif
parallel -j 20 --gnu "ffmpeg -f gif -i {} -c:v libvpx {}.vp8.webm" ::: *.gif
parallel -j 20 --gnu "ffmpeg -f gif -i {} -c:v libvpx-vp9 {}.vp9.webm" ::: *.gif
@luke3butler
luke3butler / MakeMediumReadadableUserscript.user.js
Last active March 17, 2021 22:10
Userscript version of the MMRA (Make Medium Readable Again) Chrome extension
// ==UserScript==
// @name Make Medium Readable Userscript
// @namespace http://make.medium.readable.again
// @version 0.1
// @description https://github.com/thebaer/MMRA
// @author luke3butler (Credits to Matt Baer)
// @match *://*/*
// @grant none
// ==/UserScript==
@spaceemotion
spaceemotion / OcclusionBase.cs
Created December 24, 2016 22:09
Free dynamic (run time) object occlusion scripts (https://www.reddit.com/r/Unity3D/comments/5k1gqv)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OcclusionBase : MonoBehaviour {
public bool isVisible { get; set; }
public DateTime lastSeen { get; set; }
}
@arbelt
arbelt / init.lua
Created October 2, 2016 20:55
Hammerspoon config to send escape on short ctrl press
ctrl_table = {
sends_escape = true,
last_mods = {}
}
control_key_timer = hs.timer.delayed.new(0.15, function()
ctrl_table["send_escape"] = false
-- log.i("timer fired")
-- control_key_timer:stop()
end
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

@karpathy
karpathy / min-char-rnn.py
Last active May 30, 2024 23:33
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@adamcooke
adamcooke / dsl.rb
Created November 7, 2014 15:20
The complete code from my DSL tutorial at http://blog.atechmedia.com/ruby-dsls-for-fun/
class AddressBook
def contacts
@contacts ||= []
end
def self.load_from_path(path)
# Create a new AddressBook instance
address_book = self.new
# Create a new AddressBookDSL instance
@robacarp
robacarp / a_generator_framework.md
Last active October 12, 2015 06:18
Sane, Simple Rails Generator framework to replace FactoryGirl, Machinist, Fabrication, and Rails Fixtures

##Intro

Generator frameworks spend way too much time creating obscure and pointless DSL syntax just to make the code trendy and cute. This generator comes in the form of pure ruby, instantiates real model objects (which fire their pre-, post- and other hooks appropriately), and still allows for a simple syntax to override parameters of generated objects.

Standard Ruby syntax allows for easier adoption by new programmers and reinforces ruby paradigms, instead of breaking them down with a cute, often incomplete, and entirely superfluous DSL syntax.

Specific complaints against existing frameworks:

  • Rails fixtures: definition syntax (yaml) doesn't provide a powerful enough interface to rapidly creating objects.
  • FactoryGirl: Factories are evaluated at load-time, making some factories just awful to define. No further comment on DSLs.