This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am danvonk on github. | |
* I am dvonk (https://keybase.io/dvonk) on keybase. | |
* I have a public key whose fingerprint is C786 E49F EB06 153F 7302 069E 0436 C83D 0276 F160 | |
To claim this, I am signing this object: |
This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am danvonk on github. | |
* I am dvonk (https://keybase.io/dvonk) on keybase. | |
* I have a public key ASAcbi_LCpnk6Br_izsuJ5wcjmA2YQKW6oMZpeXBgvOLcgo | |
To claim this, I am signing this object: |
This file contains 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
#include <boost/hana.hpp> | |
#include <iostream> | |
template <typename T> | |
struct basic_type { | |
using type = T; | |
}; | |
namespace hana = boost::hana; | |
using namespace hana::literals; |
This file contains 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
#!/usr/bin/ruby | |
class SparseArray | |
attr_reader :hash | |
def initialize | |
@hash = {} | |
end | |
def [](key) |
This file contains 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
/* | |
* Compile: gcc -Wall -o rf rf.c -lwiringPi | |
* Usage: sudo ./rf [binary] [delay in microseconds] [inverting bits] | |
* Example.. turning on Silvercrest outlet A | |
* sudo ./rf 11111111111111001001011001011011011011001011011011011011001001011001011011011011011011000000 500 1 | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> |
This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am danvonk on github. | |
* I am danvonk (https://keybase.io/danvonk) on keybase. | |
* I have a public key whose fingerprint is 9790 6DF8 F237 CF4B 665D BD66 8CD6 8D5B 9903 00B6 | |
To claim this, I am signing this object: |
This file contains 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
#!/usr/bin/env ruby | |
require 'benchmark' | |
def collatzSequence(x) # e.g. 916 | |
n = x | |
chain = 0 | |
loop do | |
if n % 2 == 0 | |
n = n/2 | |
chain = chain + 1 |
This file contains 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
#!/usr/bin/env ruby | |
def numDivisors(x) | |
factors = 0 | |
(2..x).take(Math.sqrt(x).to_i + 1).each do |u| | |
if x % u == 0 | |
factors += 2 | |
end | |
end | |
factors += 2 |
This file contains 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
#!/usr/bin/env ruby | |
#Convert a binary value to decimal... | |
x = 1011 | |
n = Math.log10(x).to_i + 1 | |
b = 2 #binary | |
s = 0 | |
x.to_s.chars.map(&:to_i).each do |u| | |
n = n - 1 |
This file contains 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
#!/usr/bin/env ruby | |
def getBinary(dec) | |
quot = 0 | |
binaryrep = [] | |
#do the first one manually to populate q | |
quotmod = dec.divmod(2) # [69,0] | |
q = quotmod[0] | |
binaryrep.push(quotmod[1]) |