View udp_chat.py
#!/usr/bin/env python3
"""UDP Broadcast Sender"""
import socket
import sys
PORT = 33333
def udp_send_socket():
View quit_while_youre_ahead.py
# gambling stats question
# if you play roulette every day and quit whenever you're ahead by x amount,
# do you make money in the long run?
import random
STARTING_BALANCE = 100000
BET_AMT = 100
MAX_EARNINGS = 100 * BET_AMT
MAX_LOSSES = 10 * BET_AMT
View merkel_fun.py
"""
Take a bookmark archiver folder structure and turn it into a deduped
merkel-tree blob index.
For example:
archive = {
'https://google.com': {
'index.html': 125, # arbitrary bytes as file content
'js': {
View carbon.sh.sublime-project.json
{
...,
"build_systems":
[
{
...,
"variants":
[
...,
{
View carbonify.js
#!/usr/bin/env node
/*
Submit code from stdin to carbon.now.sh and return a url to a new tweet containing a screenshot
carbon.now.sh authors: https://dawnlabs.io/
carbonify author: Nick Sweeting <git@nicksweeting.com>
MIT License 2017
*/
View event_listeners.js
import {desktopNotify, requestDesktopNotify} from '@/util/browser'
// when user clicks "notify me" checkbox
requestDesktopNotify()
store.dispatch({
type: 'ADD_EVENT_LISTENER',
pattern: 'ALERT',
handler: (action) => {
if (action.alert.subtype == 'sit_in')
View optional_args_decorator.py
def optional_arg_decorator(fn):
"""
wrap a decorator so that it can optionally take args/kwargs
when decorating a func
"""
# http://stackoverflow.com/a/32292739/2156113
@wraps(fn)
def wrapped_decorator(*args, **kwargs):
is_bound_method = args and hasattr(args[0], fn.__name__)
View immutify.js
const immutify = (obj) => {
const obj = Object.keys(obj).reduce((acc, key) => {
Object.defineProperty(acc, key, { value: obj[key], writable: false, enumerable: true})
return acc
}, {})
const hash = hashObj(obj)
Object.defineProperty(obj, 'hash', { value: hash, writable: false, enumerable: false})
Object.preventExtensions(obj)
return obj
}
View monadical-protonmail-theme.css
.headerDesktop-container{background-color:#0d0d0d}.search-form-fieldset{background:#000}[class*="searchForm-action-button-"]{color:#fff}.searchForm-action-button-advanced:hover,.searchForm-action-button-toggle:hover{background:orange}.customRadio-input:checked+.customRadio-mask{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 10px orange;border-color:orange}.pm_button.primary,.pm_button.primary:active{color:#fff;background-color:#0d0d0d;border-color:#0d0d0d}.pm_button.primary:hover,.pm_button.primary:focus{background-color:#000;border-color:#000}.navigation>li.active,.navigation>li:hover{box-shadow:0 5px 0 0 orange inset}.navigation-link{color:#fff}.navigation-title:hover{color:orange}.pm_dropdown .navigationUser-logout{background-color:#0d0d0d !important;border-color:#0d0d0d !important;color:#fff !important}.pm_dropdown .navigationUser-logout:hover{background-color:#000 !important;border-color:#000 !important;color:#fff !important}.sidebar-btn-compose,.sidebar-btn-compose:active{color:#fff !important;background:o
View fork
#!/bin/bash
/usr/local/bin/fish -c "$*" > ~/tmp/fish_forks/last.log 2>&1 &
pid=$!
mv ~/tmp/fish_forks/last.log ~/tmp/fish_forks/$pid.log
disown $pid