Skip to content

Instantly share code, notes, and snippets.

View msp's full-sized avatar

Matt Spendlove msp

View GitHub Profile
@stevenharman
stevenharman / _compose_query_objects.md
Last active December 19, 2017 21:33
Build compose-able query objects by delaying query execution and delegating to the underlying `ActiveRecord::Relation` for everything else. #ruby #rails

Compose-able Query Objects in Rails

Example usage:

old_accounts = Account.where("created_at < ?", 1.month.ago)
old_abandoned_trials = AbandonedTrialQuery.new(old_accounts)

old_abandoned_trials.find_each do |account|
 account.send_offer_for_support
@jarmitage
jarmitage / default-effects-extra.tidal
Created April 25, 2019 10:43
Tidal file for playing with new SuperDirt FX
-- New SuperDirt effects in Tidal 1.0.11
-- https://github.com/musikinformatik/SuperDirt/blob/develop/library/default-effects-extra.scd
-- https://github.com/tidalcycles/Tidal/blob/master/src/Sound/Tidal/Params.hs
let p = s "arpy*4"
{-
Waveloss
Divides an audio stream into tiny segments, using the signal's
zero-crossings as segment boundaries, and discards a fraction of them.
@serradura
serradura / firebase_admin.rb
Last active February 10, 2022 18:45
FirebaseAdmin::Auth.verify_id_token | Ruby solution for https://firebase.google.com/docs/auth/admin/verify-id-tokens
# Usage:
# ========
# FirebaseAdmin::Auth.verify_id_token(your_id_token)
#
# The method call follows the same API of the Node.js, JAVA and Python SDKs.
# See https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_the_firebase_admin_sdk
# Dependencies:
# ---------------
# gem 'activesupport'
@kosyfrances
kosyfrances / heroku_database_copy.md
Last active March 15, 2023 09:50
To copy heroku database from one app to another and from local to heroku

To copy database from one heroku app to another -

heroku pg:backups capture [database_name]
heroku pg:backups restore $(heroku pg:backups public-url --app source_app) DATABASE_URL --app target_app

You can refer to https://devcenter.heroku.com/articles/heroku-postgres-backups for more information.

To copy database from local to heroku - Dump your local database in compressed format using the open source pg_dump tool: PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump where myuser is your database username and mydb is the database name.

@jsonberry
jsonberry / onload.js
Last active July 3, 2023 14:10
Window vs. Document Loading Events
/**
Taken from: http://stackoverflow.com/questions/588040/window-onload-vs-document-onload
According to Parsing HTML documents - The end,
The browser parses the HTML source and runs deferred scripts.
A DOMContentLoaded is dispatched at the document when all the HTML has been parsed and have run. The event bubbles to the window.
The browser loads resources (like images) that delay the load event.
A load event is dispatched at the window.
Therefore, the order of execution will be
DOMContentLoaded event listeners of window in the capture phase
DOMContentLoaded event listeners of document
@jarmitage
jarmitage / tidal-multi-stream.hs
Created October 5, 2019 23:31
Multiple Tidal streams to multiple OSCTargets
-- https://tidalcycles.org/index.php/Custom_OSC
:set -XOverloadedStrings
:set prompt ""
:set prompt-cont ""
import Sound.Tidal.Context
superDirt <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cFrameTimespan = 1/20})
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@Demkeys
Demkeys / MuteTimelineTracksScript.cs
Created June 29, 2018 13:59
Example code showing how to mute Tracks in a Timeline asset.
/// <summary>
/// Instructions
/// - Create a Timeline asset. Add 3 tracks to it.
/// - Create empty GameObject in scene. Attach this script to the GameObject. Then attach a PlayableDirector component to it.
/// Drag and drop the Timeline asset you created into the Playable field of the PlayableDirector.
/// - Hit Play. The 1, 2 and 3 keys on your keyboard mute the first, second and third tracks respectively.
/// </summary>
using System.Collections;
using System.Collections.Generic;
@Bonno
Bonno / mp4-to-wav
Created February 10, 2015 09:24
Convert mp4 to WAV with ffmpeg
ffmpeg -i <infile> -ac 2 -f wav <outfile>
@gunderson
gunderson / FlyCamera.cs
Last active January 15, 2024 16:31
Unity Script to give camera WASD + mouse control
using UnityEngine;
using System.Collections;
public class FlyCamera : MonoBehaviour {
/*
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care.
Converted to C# 27-02-13 - no credit wanted.
Simple flycam I made, since I couldn't find any others made public.
Made simple to use (drag and drop, done) for regular keyboard layout