Skip to content

Instantly share code, notes, and snippets.

View ZuraGuerra's full-sized avatar
🐟
🌏🌎🌍

Zura Guerra ZuraGuerra

🐟
🌏🌎🌍
View GitHub Profile
@obmarg
obmarg / system_metrics.ex
Created February 8, 2016 12:56
Reading /proc/loadavg in elixir using with statements.
defmodule SystemMetrics do
# Gets the load average.
def loadavg do
res =
with {:ok, data} <- read_file("/proc/loadavg"),
[one, five, fifteen | _] <- String.split(data, " "),
{one, ""} <- Float.parse(one),
{five, ""} <- Float.parse(five),
{fifteen, ""} <- Float.parse(fifteen),
do: ["1": one, "5": five, "15": fifteen]
@jwhiteman
jwhiteman / binary_tree.exs
Created January 22, 2016 02:45
invert a binary tree in Elixir
# http://is.gd/NzZxYT
defmodule BinaryTree do
def invert([n, list]) when is_integer(n) and is_list(list) do
[n, invert(list)]
end
def invert([n, nc, m, mc])
when is_integer(n) and is_integer(m)
and is_list(nc) and is_list(mc) do
@marick
marick / about_those_lava_lamps.md
Last active June 22, 2022 21:08
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

@popravich
popravich / PostgreSQL_index_naming.rst
Last active May 30, 2024 06:39
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@joshrieken
joshrieken / Gulpfile.js
Last active July 10, 2019 15:33
Replacing Brunch with Gulp in Phoenix
// Contains support for: SASS/SCSS, concatenation, and minification for JS and CSS
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var concat = require('gulp-concat');
var compress = require('gulp-yuicompressor');
@petrkohut
petrkohut / howto.md
Last active October 20, 2021 08:57
How to have redis-cli and psql installed on machine using Docker

How to install redis-cli and psql client on your machine with Docker

Preparing docker images

We will use minimalistic Linux distribution called Alpine (5MB)

Dockerfile of redis-cli

FROM alpine:latest
RUN apk --update add redis
@ju2wheels
ju2wheels / Dockerfile
Last active March 9, 2024 13:37
Docker Dockerfile reference template
# Last updated: 08/24/2916
#
# Total instructions available: 18
#
# https://docs.docker.com/engine/reference/builder/
#
# You can use a .dockerignore file in the same context directory as
# your Dockerfile to ignore files in the context before sending them
# to the Docker daemon for building to speed up building.
@simonc
simonc / Grooveshark Backup.md
Last active March 27, 2019 14:25
Go to grooveshark and type this in the development console (Thank you audiosplitter.fm !!)

Backup for Grooveshark Collection

This works even with Grooveshark dead!

The awesome people at audiosplitter.fm provide a little code snippet that allows you to get your Grooveshark collection back.

Go to http://grooveshark.com and open your browser devtools, go to the Console tab and type the content of the JS script. You'll get a big JSON blob, if you know how to exploit it good for you, if not audiosplitter.fm can import it, go use it ;)

@jordwest
jordwest / Makefile
Created April 20, 2015 06:23
Simple front-end builds with Makefiles
# Specify directories under /client/src to be copied directly
COPYDIRS = lib img
client: copy client/build/js/app.js client/build/css/app.css
clean:
rm -Rf client/build
rebuild: clean client
@emilbjorklund
emilbjorklund / Pseudo-makefile
Last active January 21, 2020 22:27
Makefile for Sass?
# This is probably some pseudo-makefile syntax, but basically I want to do this:
# - The `assets/scss/` dir has a bunch of "top level" Sass files to
# be compiled - foo.scss, bar.scss etc.
# - Note: these files will each generate one resulting .css file of the
# same name as the source inside the build dir. foo.scss -> foo.css etc.
# - The build needs to be re-run any time any partial inside of a
# subdir in the scss folder changes: if `assets/scss/baz/_baz.scss` changes,
# I want to recompile all of the "root" .scss files.
# I.e. all of the partials in subdirs are prerequisites.