Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Allick chrisallick

View GitHub Profile
View gitToMP4.rb
#
# run from root
#
# writes to a folder "videos" folder needs to be created.
# requires ffmpeg installed
#
# $>ruby gifToMP4.rb
#
#
# references:
@chrisallick
chrisallick / index.html
Created Nov 5, 2019
contentful_s3_image_ui_extension_index.html
View index.html
<!DOCTYPE html>
<html>
<head>
<!-- Contentful dependencies -->
<link rel="stylesheet" href="https://contentful.github.io/ui-extensions-sdk/cf-extension.css">
<script src="https://unpkg.com/contentful-ui-extensions-sdk@3"></script>
<!-- AWS JS SDK -->
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.120.0.min.js"></script>
@chrisallick
chrisallick / auto-nvm-use.sh
Created Apr 2, 2019
auto-switch node version when you cd into project directory
View auto-nvm-use.sh
#
# Run 'nvm use' automatically every time there's
# a .nvmrc file in the directory. Also, revert to default
# version when entering a directory without .nvmrc
#
enter_directory() {
if [[ $PWD == $PREV_PWD ]]; then
return
fi
View emailer_sender.rb
require 'aws-sdk-lambda' # https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/ruby/example_code/lambda/aws-ruby-sdk-lambda-example-run-function.rb
require 'json'
require 'sendgrid-ruby'
include SendGrid # https://github.com/sendgrid/sendgrid-ruby
Encoding.default_external = 'UTF-8'
class EmailSender
View email_sender.rb
require 'aws-sdk-lambda' # https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/ruby/example_code/lambda/aws-ruby-sdk-lambda-example-run-function.rb
require 'json'
require 'sendgrid-ruby'
include SendGrid # https://github.com/sendgrid/sendgrid-ruby
Encoding.default_external = 'UTF-8'
class EmailSender
View app.rb
require 'base64'
require 'openssl'
require 'sinatra'
require 'sinatra/partial'
require 'sinatra/reloader' if development?
require 'resque'
require './email_sender'
@chrisallick
chrisallick / currently_playing.rb
Last active Aug 1, 2018
Pipe what is playing on spotify into a file for BUTT (broadcast using this tool)
View currently_playing.rb
#!/usr/bin/env ruby
require 'rubygems'
# usage
# ./currently_playing.rb > currently_playing.txt
def osascript(script)
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
end
@chrisallick
chrisallick / instascrape.rb
Created Apr 11, 2018
scrape instagram html json
View instascrape.rb
require 'rubygems'
require 'open-uri'
require 'json'
require 'nokogiri'
doc = Nokogiri::HTML(open("https://www.instagram.com/chrisallick/"))
data = ""
doc.css('script').each do |script|
@chrisallick
chrisallick / blockchain.rb
Created Jul 18, 2017
tiny blockchain in ruby
View blockchain.rb
#https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b
#http://ruby-for-beginners.rubymonstas.org/writing_classes/self.html
#https://stackoverflow.com/questions/33768598/ruby-sha-256-hexidigest-values-are-different-from-what-python-generates
#import hashlib as hasher
require "rubygems"
require "digest"
# class Block:
# def __init__(self, index, timestamp, data, previous_hash):
@chrisallick
chrisallick / sketch.js
Created Dec 7, 2016
preload, play, and crossfade audio tracks in p5js
View sketch.js
var audio = [];
var numTracks = 4;
function preload() {
audio[0] = loadSound('/audio/001.mp3');
audio[1] = loadSound('/audio/002.mp3');
audio[2] = loadSound('/audio/003.mp3');
audio[3] = loadSound('/audio/004.mp3');
}
You can’t perform that action at this time.