Skip to content

Instantly share code, notes, and snippets.

View igas's full-sized avatar

Marcus Wood igas

View GitHub Profile
@evadne
evadne / a-reverse-bench.exs
Last active January 5, 2024 10:57
Reversing Binaries in Elixir
defmodule Benchmarker do
def run(title, module, function, size \\ 1024, iterations \\ 100) do
times = for (_ <- 1 .. iterations) do
data = :crypto.strong_rand_bytes(size)
{duration, _value} = :timer.tc fn ->
apply(module, function, [data])
end
duration
end
@koudelka
koudelka / lookup.ex
Created October 2, 2015 21:13
Elixir Set Lookup
defmodule Lookup do
@wordfile "words.txt"
@external_resource @wordfile
@times 1_000_000
@words @wordfile |> File.stream! |> Enum.map(&String.strip/1)
@hash_set Enum.into(@words, HashSet.new)
@map_set Enum.into(@words, MapSet.new)
@brianstorti
brianstorti / priority_queue.rb
Last active November 17, 2022 16:14
Priority queue implementation in Ruby
class PriorityQueue
attr_reader :elements
def initialize
@elements = [nil]
end
def <<(element)
@elements << element
bubble_up(@elements.size - 1)
@ericelliott
ericelliott / essential-javascript-links.md
Last active April 22, 2024 10:15
Essential JavaScript Links
@jeromedalbert
jeromedalbert / configure_osx.sh
Last active February 8, 2016 00:04
Configure OSX Yosemite with sensible defaults
# Disable the "Are you sure you want to open this application?" dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 2
# Decrease the initial time before a keyboard repeat
@pnc
pnc / observer.md
Last active September 9, 2023 23:32
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
def gen_module(file, rest_body) do
# load things from the file here and assign them to variables
Module.create(<name>, quote bind_quoted: [rest_body: rest_body, var1: var1, ...] do
# now unquote() can be called here freely, it will be deferred until module compilation
# therefore, you can copy-paste your previous in-line code without the file loading part
def unquote(...)(...) do
unquote(...)
end
...
iex> use PipeInspect
nil
iex> "hello" |> String.reverse |> String.upcase |> String.downcase
"olleh"
"OLLEH"
"olleh"
@kirs
kirs / Dockerfile
Created March 21, 2014 07:11
chruby + 2.0.0-p451 docker image
FROM ubuntu:precise
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -q -y wget
RUN apt-get install -q -y ca-certificates
RUN apt-get install -q -y make
## Ruby-install
@niquola
niquola / list.md
Last active May 20, 2018 04:52
Must Read from Ravil Bayramgalin (https://github.com/brainopia) + my small adds :)

Books

Concepts-Techniques-Models-Computer-Programming CMT это известная книжка CMT, за которой слава закрепилась не хуже чем у SICP

это из этой книжки классификация различных парадигм Если присмотришься, то увидишь, что Oz поддерживает большинство вариаций (с этой целью его и конструировали, чтобы можно было наглядно продемонстрировать различные подходы в одном языке)