Skip to content

Instantly share code, notes, and snippets.

View randito's full-sized avatar
:octocat:
(⊙_⊙)

Randy Pond randito

:octocat:
(⊙_⊙)
View GitHub Profile
@randito
randito / phx_sqlite_fly_launch.md
Created January 1, 2023 22:11 — forked from mcrumm/phx_sqlite_fly_launch.md
Phoenix + SQLite Deployment tips

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

@randito
randito / setup.sh
Created November 30, 2020 16:31 — forked from Gazler/setup.sh
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
@randito
randito / Dockerfile
Created March 4, 2020 17:26 — forked from juanpabloaj/Dockerfile
elixir and phoenixframework with docker-compose
FROM elixir:slim
# install Node.js (>= 8.0.0) and NPM in order to satisfy brunch.io dependencies
# See https://hexdocs.pm/phoenix/installation.html#node-js-5-0-0
RUN apt-get update -y && \
apt-get install -y curl git && \
curl -sL https://deb.nodesource.com/setup_13.x | bash - && \
apt-get install -y inotify-tools nodejs
WORKDIR /code

Keybase proof

I hereby claim:

  • I am randito on github.
  • I am randito (https://keybase.io/randito) on keybase.
  • I have a public key ASBHQ_4YjXW4eqaOFvMLIE2TxbMD_n-wjIA0AQRuQt7M8wo

To claim this, I am signing this object:

@randito
randito / latency.txt
Created February 17, 2019 01:56 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@randito
randito / hello1.maditu
Created October 12, 2018 19:15
Maditu POC (using blocks)
# other, self
listen { |other|
other_name = other.name
}
run { |other|
puts "Other name"
puts other.name
puts "Self name"
puts self.name
@randito
randito / todos_controller.coffee
Created March 27, 2014 16:03
Ember example controller (in coffeescript)
# From: http://emberjs.com/guides/getting-started/creating-a-new-model/
Todos.TodosController = Ember.ArrayController.extend
actions:
createTodo: ->
title = @get 'newTitle'
return unless title.trim()
@set 'newTitle', ''
@store.createRecord 'todo',
title: title
@randito
randito / insult.rb
Created November 21, 2012 00:02
Shakespearen insult generator
#!/usr/bin/env ruby -wKU
regexp = /\w+-*\w+/ # i.e hugger-mugger
triplets = ::DATA.readlines.map { |line| line.scan(regexp) }
insults = triplets.select { |t| t.size == 3 }
thousts = [
'Thoust',
'Thou',
'You',
$ time ./perfect_number.rb 8028
6
28
496
./perfect_number.rb 8028 0.53s user 0.01s system 99% cpu 0.544 total
This optimized version is *much* better than the original at https://gist.github.com/3961422
$ time ./perfect_number.rb 10000
6
28
496
8128
./perfect_number.rb 10000 17.81s user 0.01s system 99% cpu 17.833 total