Skip to content

Instantly share code, notes, and snippets.

@voluntas
voluntas / sysctl.conf
Created October 14, 2017 13:07 — forked from techgaun/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
(fun() ->
SizePids = lists:flatmap(fun(Pid) ->
Size = case process_info(Pid, binary) of
{binary, BinInfos} ->
lists:sum([S || {_, S, _} <- BinInfos]);
undefined ->
0
end,
if Size == 0 -> []; true ->
[{Size, Pid}]
@lrascao
lrascao / gist:6880485b8dc4c51c74392b0fa5b9d358
Last active December 29, 2023 12:29
Build Erlang statically linked with OpenSSL
sudo yum install gcc gcc-c++ make libxslt fop ncurses-devel openssl-devel *openjdk-devel unixODBC unixODBC-devel
KERL_CONFIGURE_OPTIONS="--with-ssl=/home/ec2-user/openssl/releases/1.0.2h --disable-dynamic-ssl-lib" kerl build 18.3 18.3
# without ECC
KERL_CONFIGURE_OPTIONS="CFLAGS=-DOPENSSL_NO_EC=1" kerl build 18.3 18.3
@jlroettger
jlroettger / ReorderableList.js
Created August 30, 2016 00:53
React DND and Material UI - Reorderable List
import React, { Component } from 'react'
import { Link } from 'react-router'
// Drag and Drop
import { DragDropContext } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
// Material UI
import { List } from 'material-ui/List'
import Subheader from 'material-ui/Subheader'
class ReorderableList extends Component {
@jadeallenx
jadeallenx / discussion.md
Last active April 21, 2023 17:13
When does terminate/2 get called in a gen_server?

When does terminate/2 get called in a gen_server?

This is what the [official documentation][1] says about the terminate/2 callback for a gen_server:

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Reason is a term denoting the stop reason and State is the internal state of the gen_server.

Reason depends on why the gen_server is terminating. If it is because another callback function has returned a stop tuple {stop,..}, Reason will have the value specified in that tuple. If it is due to a failure, Reason is the error reason.

@robinsmidsrod
robinsmidsrod / inventory.ipxe
Created July 16, 2015 22:48
iPXE hardware inventory script (from svenx)
# Run a PCI/SMBios/net inventory scan and upload the results. This gives us a
# way of tracking nodes to some extent, leaving us less blind than usual.
#
# We use the iPXE pciscan command to enumerate the PCI bus. For each device, we
# check the 'header type' register at offset 0x0e. If it's type 0 (endpoint),
# we can read the subsystem vendor and device registers too. Unfortunately, if
# the 7th bit of the header type field is set (0x80), it indicates a
# multi-function device. So to check the type, this bit should be masked out.
# Masking is not possible with iPXE commands, so we have to duplicate some of
# the iseq tests.
@indykish
indykish / riak.service
Last active April 15, 2019 10:20
Archlinux riak systemd service with ulimit fix
#Checkout for a free launch at, https://www.megam.io
[Unit]
Description=Distributed key/value store from Basho Technologies
After=network.target
[Service]
LimitNOFILE=infinity
LimitMEMLOCK=infinity
User=riak
Type=forking
@jaredmorrow
jaredmorrow / read_write_fifo_erlang.md
Last active April 22, 2023 20:05
Reading and Writing to Fifo (named pipes) in Erlang

edit

@akash-akya pointed out in the comments that the file module supports named pipes since OTP 20. So none of this post is really needed anymore if you are on >= OTP 21.


Erlang and Named Pipes

The intention of this post is to provide a solution (with examples) to a somewhat uncommon issue in Erlang. I hate searching for answers to the same problems over and over, and I had a hard time finding answers to this particular problem, so I wrote it all down once I figured it out. If one day you decide to read and write data through fifo's (named pipes) and then decide you want to read or write the other end of the pipe from Erlang, this post is for you.

@okeuday
okeuday / immediate_gc.erl
Created September 23, 2014 05:08
Immediate Garbage Collection in Erlang (as harsh as possible)
%-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*-
% ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et:
%%%
%%%------------------------------------------------------------------------
%%% @doc
%%% ==Enforce immediate garbage collection on a function==
%%% @end
%%%
%%% BSD LICENSE
%%%
@smoser
smoser / gist:4756561
Last active November 8, 2023 15:20
boot a cloud image in kvm
## Install a necessary packages
$ sudo apt-get install kvm cloud-utils genisoimage
## URL to most recent cloud image of 12.04
$ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release"
$ img_url="${img_url}/ubuntu-12.04-server-cloudimg-amd64-disk1.img"
## download the image
$ wget $img_url -O disk.img.dist
## Create a file with some user-data in it