Skip to content

Instantly share code, notes, and snippets.

Chris Raethke codesoda

Block or report user

Report or block codesoda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View number.js
const padLeft = (number, n,str) => {
return number.toString().length >= n ? number : Array(n-String(number).length + 1).join(str||'0') + number;
}
const playTime = (milliseconds) => {
let seconds = milliseconds / 1000.0,
hours = Math.floor(seconds / 3600),
minutes = Math.floor((seconds % 3600) / 60),
only_seconds = Math.round(seconds % 60),
parts = [];
@codesoda
codesoda / Gemfile
Created Jan 11, 2018 — forked from chezou/Gemfile
Example code of ruby with Amazon Polly
View Gemfile
source 'https://rubygems.org'
gem 'nokogiri', '~>1.6'
gem 'aws-sdk', '~> 2'
@codesoda
codesoda / API.md
Created Sep 4, 2017 — forked from iros/API.md
Documenting your REST API
View API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@codesoda
codesoda / check.sh
Created Sep 9, 2016
Check apple store to see if iphone is available yet
View check.sh
main() {
while [[ true ]]; do
local request="$(curl -s 'http://www.apple.com/us/shop/goto/iphone_7/select' | grep 'be back soon')"
if [[ ! $request ]]; then
say 'Yep, time to buy'
break
fi
View my_class.rb
# this is running in Project 2
class MyClass
def some_process
# if the worker was in this project I could do this
# MyWorker.perform_async(...args)
# but the worker isn't in my project
# I always thought I could do this, but it seems it needs
# class: ActualClass,
# not
@codesoda
codesoda / typekit.js
Created Jun 28, 2016
Typekit + sessionstorage + no FOUT
View typekit.js
<script>
(function(d) {
var tkTimeout=3000;
if(window.sessionStorage){if(sessionStorage.getItem('useTypekit')==='false'){tkTimeout=0;}}
var config = {
kitId: 'abc1234',
scriptTimeout: tkTimeout
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";if(window.sessionStorage){sessionStorage.setItem("useTypekit","false")}},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='//use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
@codesoda
codesoda / Guardfile
Last active May 12, 2016
Guard Error
View Guardfile
# use mac notification center
notification :terminal_notifier
guard :rspec, cmd: 'bin/rspec' do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
# Feel free to open issues for suggestions and improvements
# RSpec files
@codesoda
codesoda / base.rb
Created Sep 28, 2015 — forked from bensie/base.rb
Sinatra API Helpers
View base.rb
require "sinatra/base"
require "sinatra/namespace"
require "multi_json"
require "api/authentication"
require "api/error_handling"
require "api/pagination"
module Api
class Base < ::Sinatra::Base
@codesoda
codesoda / rspec_model_testing_template.rb
Last active Aug 29, 2015 — forked from kyletcarlson/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@codesoda
codesoda / .rspec
Last active Aug 29, 2015
Sinatra Template
View .rspec
--color
--format Fuubar
--require spec_helper
You can’t perform that action at this time.