Skip to content

Instantly share code, notes, and snippets.

@dbswebsite
dbswebsite / normalize.sh
Last active December 21, 2020 11:59
Normalize image filenames, recursively.
#!/bin/bash
#
# @file normalize.sh
#
# @requires the perl 'rename' utility
#
################################################################################
# force to lowercase
find . -iregex ".+\.\(jpe?g\|png\)" | rename 'y/A-Z/a-z/'
@richy486
richy486 / BrickMaker.swift
Created December 21, 2015 20:51
Playing with Protocols as Types
// https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html
print("Brick maker!")
// for testing on http://swiftlang.ng.bluemix.net/
typealias CGFloat = Float
struct CGPoint {
var x: CGFloat
var y: CGFloat
@zachloubier
zachloubier / youtube_next.applescript
Created December 3, 2015 01:05
Scripts for controlling YouTube videos. Inspiration taken from https://gist.github.com/fent/7763775
# Next Youtube Video in Playlist
tell application "Google Chrome"
repeat with t in tabs of windows
tell t
if URL starts with "http://www.youtube.com/watch" or URL starts with "https://www.youtube.com/watch" then
execute javascript "
var player = document.getElementById('movie_player') || document.getElementsByTagName('embed')[0];
if (player) {
document.getElementsByClassName('ytp-next-button')[0].click()
@jkosoy
jkosoy / CGSize+AspectFunctions.swift
Last active June 3, 2023 18:11
Aspect Fill and Aspect Fit calculations in Swift
// port of http://stackoverflow.com/a/17948778/3071224
import UIKit
import Foundation
extension CGSize {
static func aspectFit(aspectRatio : CGSize, var boundingSize: CGSize) -> CGSize {
let mW = boundingSize.width / aspectRatio.width;
let mH = boundingSize.height / aspectRatio.height;
@richy486
richy486 / FTButtonNode.swift
Created November 8, 2015 22:47
Button node for Sprite kit in swift 2.1
// Button node for Sprite kit in swift 2.1
// http://stackoverflow.com/questions/19082202/setting-up-buttons-in-skscene
import Foundation
import SpriteKit
class FTButtonNode: SKSpriteNode {
enum FTButtonActionType: Int {
case TouchUpInside = 1,
@RadGH
RadGH / short-number-format.php
Last active February 25, 2025 21:33
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
@Two9A
Two9A / decronym.php
Last active January 22, 2025 17:46
Decronym: A simple Reddit bot
<?php
/**
* Dirty, dirty Reddit bot: Decronym
*/
class Reddit {
const USERNAME = 'Decronym';
const PASSWORD = '***';
const CLIENTID = '***';
const SECRET = '***';
@ainoya
ainoya / SKAction+Extensions.swift
Created July 12, 2015 18:46
Swift Extensions for SKAction.playSoundFileNamed() with custom volume
// reference: https://github.com/pepelkod/iOS-Examples/blob/master/PlaySoundWithVolume/PlaySoundWithVolumeAction.m
import SpriteKit
public extension SKAction {
public class func playSoundFileNamed(fileName: String, atVolume: Float, waitForCompletion: Bool) -> SKAction {
let nameOnly = fileName.stringByDeletingPathExtension
let fileExt = fileName.pathExtension
@protrolium
protrolium / ffmpeg.md
Last active April 8, 2025 01:38
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@chantastic
chantastic / on-jsx.markdown
Last active November 10, 2024 13:39
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't