This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float dbToVolume(float dB) | |
{ | |
return powf(10.0f, 0.05f * dB); | |
} | |
float volumeTodB(float volume) | |
{ | |
return 20.0f * log10f(volume); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://github.com/jnunemaker/httparty/issues/406#issuecomment-239542015 | |
module Net::HTTPHeader | |
def capitalize(name) | |
name | |
end | |
private :capitalize | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google/apis/admin_directory_v1' | |
require 'googleauth' | |
require 'googleauth/stores/file_token_store' | |
require 'fileutils' | |
OOB_URI = 'urn:ietf:wg:oauth:2.0:oob' | |
APPLICATION_NAME = 'Directory API Ruby Quickstart' | |
CLIENT_SECRETS_PATH = 'client_secret.json' | |
CREDENTIALS_PATH = File.join(Dir.home, '.credentials', "admin-directory_v1-ruby-quickstart.yaml") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# you need ffmpeg and gifsicle installed. they're available via brew on a mac. | |
# sips will already be installed on your mac. | |
# you probably want an existence check here, but I'm lazy. | |
rm out.gif | |
mkdir pngs | |
# you can change 450 to your desired output width. the aspect ratio will be preserved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filename = ARGV.first | |
puts "Opening #{filename}" | |
file = File.open(filename) | |
puts "Reading contents" | |
contents = file.read.encode('UTF-8', invalid: :replace) | |
puts "Splitting into requests" | |
requests = contents.split("\n\n\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Oceanic Next Color Scheme/Oceanic Next.tmTheme", | |
"create_window_at_startup": false, | |
"draw_white_space": "selection", | |
"ensure_newline_at_eof_on_save": true, | |
"fade_fold_buttons": false, | |
"font_face": "SF Mono Regular", | |
"font_size": 10.0, | |
"highlight_line": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check for existing swaps: | |
swapon -s | |
# None listed? Then go for it! | |
# Create ~8GB empty file | |
sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=8192 | |
# Lock it down |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionController | |
class Parameters | |
def insist(*filters) | |
filters.each { |f| ensure_presence(f) } | |
permit(filters) | |
end | |
private | |
def ensure_presence(filter, params = self) | |
case filter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/append_routes.rb | |
# Basically this: http://experiments.openhood.com/rails/rails%203/2010/07/20/add-routes-at-runtime-rails-3/ | |
# but in a re-usable block format. | |
def append_routes(&block) | |
begin | |
_routes = Rails.application.routes | |
_routes.disable_clear_and_finalize = true | |
_routes.clear! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
module Test | |
class UploadedFile | |
def tempfile | |
self | |
end | |
end | |
end | |
end |