Skip to content

Instantly share code, notes, and snippets.

# Get the count of each character in a file
filename = ARGV[0]
file = File.new(filename)
chars = {} of String => Int32
while true
r = file.gets(1)
@daviscodesbugs
daviscodesbugs / makewave.cr
Created December 14, 2018 04:07
Make Waves
# http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
# http://soundfile.sapp.org/doc/WaveFormat/
filename = ARGV[0]
filesize = File.size(filename)
puts "Reading #{filename} (#{filesize} bytes)"
# Constant
chunkID = "RIFF"
format = "WAVE"
@daviscodesbugs
daviscodesbugs / audio2video.sh
Created August 16, 2018 16:12
Create still image video with audio
#!/bin/bash
ffmpeg -loop 1 -i image.jpg -i audio.mp3 -c:a copy -c:v libx264 -shortest audio.mp4
@daviscodesbugs
daviscodesbugs / keybase.md
Created December 13, 2017 01:04
Keybase Proof

Keybase proof

I hereby claim:

  • I am daviscodesbugs on github.
  • I am thedavispearson (https://keybase.io/thedavispearson) on keybase.
  • I have a public key whose fingerprint is 1256 BD6B 8F6C B5E4 3667 F1AB 93D0 4BB2 362C 8EE7

To claim this, I am signing this object:

Git

Ignore future changes to a file

git update-index --skip-worktree file.txt
@daviscodesbugs
daviscodesbugs / expose
Last active February 28, 2018 14:56
Quick Scripts
#!/bin/bash
# Need NPM package localtunnel-cli installed
while :
do
lt --subdomain <subdomain> --port 80
done
@daviscodesbugs
daviscodesbugs / windows.ps1
Created May 1, 2017 04:46
Useful Windows Commands
# Get Windows Product Key
(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

Keybase proof

I hereby claim:

  • I am daviscodesbugs on github.
  • I am dpearson (https://keybase.io/dpearson) on keybase.
  • I have a public key ASDot1hi9wA4nXBLDxtwmSsVkrkr0sQE4NKBzstcDI4ufwo

To claim this, I am signing this object:

@daviscodesbugs
daviscodesbugs / interview.rb
Created December 8, 2016 23:57
Interview Questions
# Given an array, output all possible subsets
# An array of length n has 2^n subsets
def subsets(arr)
return [arr] if arr == []
subs = subsets(arr.drop(1))
subs + subs.map {|x| [arr.first] + x}
end