Skip to content

Instantly share code, notes, and snippets.

View unforced's full-sized avatar

Aaron Gabriel Neyer unforced

View GitHub Profile
@unforced
unforced / githubcrash.rb
Created March 7, 2013 17:12
Crashes github_api
require 'github_api'
@user = "rubinius"
@repo = "rubinius"
@github = Github.new(oauth_token: "redacted")
begin
@github.repos.commits.get(@user, @repo, "ceb66b61264657898cd6608c7e9ed78072169664")
rescue Github::Error::NotFound
end
begin
@github.repos.commits.get(@user, @repo, "1754bd9b208e8d9207c226d1ffb3cee490856a78")
[22] pry(main)> x = 5.days
=> 432000
[23] pry(main)> y = 432000
=> 432000
[24] pry(main)> z = Date.today
=> Fri, 21 Jun 2013
[25] pry(main)> z-x
=> Sun, 16 Jun 2013
[26] pry(main)> z-y
=> Wed, 07 Sep 0830
@unforced
unforced / gist:6177101
Last active December 20, 2015 18:39
Ruby mutable args
class Foo
X = 10
def self.bar(a: X)
a
end
end
Foo.bar #=> 10
class Foo
@unforced
unforced / gist
Last active December 21, 2015 03:58
Tmux 1.8 CentOS
# I had problems with using ncurses from source, so just use the one from Yum
sudo yum install gcc kernel-devel make ncurses-devel
# Download, build, and install libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
make && sudo make install
while(true) {
Socket socket = serverSocket.accept();
new Thread(new Runnable() {
@Override
public void run() {
doSomeStuff(socket);
socket.close(); // Can also just close it in doSomeStuff
}
})
}
D/PBL-BT (13805): 09:40:45.238 BluetoothConnectionManager.unregisterHandler():161> Unregistered new protocol handler 'APP_INSTALL_MANAGER'
D/PBL-BT (13805): 09:40:45.246 BluetoothConnectionManager.unregisterHandler():161> Unregistered new protocol handler 'VERSIONS'
I/PblAndroid(13805): Firmware Version Info time=4 git=32 gitcomit=8 Recoverf=1 hw=1 md=1
D/PBL-BT (13805): 09:40:45.269 VersionsResponse$FirmwareVersionInfo.fromByteBuffer():528> VersionBuffer=[size=[150] =[0[0]1[-106]2[0]3[16]4[1]5[83]6[6]7[86]8[-59]9[118]10[50]11[46]12[48]13[46]14[49]15[0]16[0]17[0]18[0]19[0]20[0]21[0]22[0]23[0]24[0]25[0]26[0]27[0]28[0]29[0]30[0]31[0]32[0]33[0]34[0]35[0]36[0]37[0]38[0]39[0]40[0]41[51]42[52]43[56]44[101]45[51]46[98]47[54]48[0]49[0]50[4]51[1]52[80]53[-9]54[-119]55[-115]56[118]57[49]58[46]59[53]60[46]61[52]62[0]63[0]64[0]65[0]66[0]67[0]68[0]69[0]70[0]71[0]72[0]73[0]74[0]75[0]76[0]77[0]78[0]79[0]80[0]81[0]82[0]83[0]84[0]85[0]86[0]87[0]88[57]89[98]90[50]91[52]92[49]93[51]94[52]95[0]96[1]97[4]98[1]99[81]100[103]101
@unforced
unforced / keybase.md
Created October 10, 2014 14:26
keybase.md

Keybase proof

I hereby claim:

  • I am aaronneyer on github.
  • I am aaronneyer (https://keybase.io/aaronneyer) on keybase.
  • I have a public key whose fingerprint is B44F D277 0334 D4D4 4567 58EB A272 4BBC 7DD8 B9F0

To claim this, I am signing this object:

@unforced
unforced / gist:adeedfe992002fa4bfdd
Last active August 29, 2015 14:09
Project Euler Problem 2
(defn fib [a b] (lazy-seq (cons a (fib b (+ a b)))))
(reduce + (filter even? (take-while #(< % 4000000) (fib 1 2))))
13322639298622611478895430296767243190917686103670655653666384229717639662844125177558472495698579173351112168113873051102932351131978903723133848878333952258195745648802418758724850033045160926402166301919183983316384838026935018685864226697381484726620154118210960605158455039013369115249425089559061028913587380830411588870008031978175295335955935148859018791618848630146401877516417990432589688468091505671577106738918725966287074335493320638196187126288363016477831317009523987599548468025431856813093966860915037218102763499996037211921875787996967555813958387388353631582410539561786770137240611405701563319955560959136357966831851836261153874221571759368754800706880734811813434828702753877761093601370046097880561890982043212845341614707476416431663684657274431523523473074037233139395722210223121758592472899957990538230596046713232016771080846729579078038221237533794949907840727963024633303784
(defn fib [a b] (lazy-seq (cons a (fib b (+ a b)))))
(reduce + (filter even? (take-while #(< % 4000000) (fib 1 2))))
; Redacted problem 2 answer
(count (str (nth (fib (bigint 1) (bigint 2)) 400000)))
; 83596
(count (str (nth (fib (bigint 1) (bigint 2)) 4000000)))
; 835951
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y ruby2.2.1 git
RUN apt-get clean
RUN gem install bundler
RUN locale-gen en_US en_US.UTF-8
EXPOSE 8080
RUN git clone https://github.com/cwruacm/acm.case.edu /opt/acm/
RUN cd /opt/acm && bundle install