Skip to content

Instantly share code, notes, and snippets.

@niahoo
niahoo / images.ex
Last active March 15, 2017 16:30
A simple way to have specific static files in memory at any time in elixir with infinite concurrency
defmodule Images do
def image_content(_, 0),
do: unquote(File.read!("path/to/empty/image.png"))
for lang <- ["en", "de", "fr"], amount <- 1..11 do
binary = File.read!(__DIR__ <> "/images/#{lang}-#{amount}.png")
def image_content(unquote(lang), unquote(amount)),
do: unquote(binary)
end
@niahoo
niahoo / Preferences.sublime-settings
Created January 19, 2017 15:07
This my configuration for Sublime Text 3
{
"always_show_minimap_viewport": true,
"binary_file_patterns":
[
"*.beam",
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
@niahoo
niahoo / delete-all-messages.js
Last active September 20, 2023 01:29
Delete all messages in a Discord channel
(function(){
// Paste your token between the quotes :
var authToken = '________________________________________'
// https://github.com/yanatan16/nanoajax
!function(t,e){function n(t){return t&&e.XDomainRequest&&!/MSIE 1/.test(navigator.userAgent)?new XDomainRequest:e.XMLHttpRequest?new XMLHttpRequest:void 0}function o(t,e,n){t[e]=t[e]||n}var r=["responseType","withCredentials","timeout","onprogress"];t.ajax=function(t,a){function s(t,e){return function(){c||(a(void 0===f.status?t:f.status,0===f.status?"Error":f.response||f.responseText||e,f),c=!0)}}var u=t.headers||{},i=t.body,d=t.method||(i?"POST":"GET"),c=!1,f=n(t.cors);f.open(d,t.url,!0);var l=f.onload=s(200);f.onreadystatechange=function(){4===f.readyState&&l()},f.onerror=s(null,"Error"),f.ontimeout=s(null,"Timeout"),f.onabort=s(null,"Abort"),i&&(o(u,"X-Requested-With","XMLHttpRequest"),e.FormData&&i instanceof e.FormData||o(u,"Content-Type","application/x-www-form-urlencoded"));for(var p,m=0,v=r.length;v>m;m++)p=r[m],void 0!==t[p]&&(f[p]=t[p]);for
@niahoo
niahoo / Preferences.sublime-settings
Last active February 15, 2016 10:00
niahoo's Sublime Text 3 Settings
{
"always_show_minimap_viewport": true,
"binary_file_patterns":
[
".beam",
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
@niahoo
niahoo / sortby.js
Created December 7, 2015 15:17
Javascript browser sortBy function
(function(){
function get(k) {
return function(o) {
return o[k]
}
}
function maybeWrap(callback) {
// substitute a string to a callback to define a property getter
-module(random_server).
-include("../include/debugtools.hrl").
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
-export([start_link/0]).
@niahoo
niahoo / index.html
Created August 21, 2015 14:44
Calcul de temps d'attentes aux ascenseurs pour deux algorithmes différents
<!doctype html>
<html lang='en-GB'>
<head>
<meta charset='utf-8'>
<title>Ractive test</title>
</head>
<body>
<style type="text/css" media="screen">
#container {
@niahoo
niahoo / index.html
Last active August 29, 2015 14:24
Removin' item list, pure CSS transitions
<!doctype html>
<meta charset="utf-8" />
<style type="text/css">
* {
margin:0;
padding:0;
font-family: monospace;
}
var uk = {"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"MultiPolygon","coordinates":[[[[-0.882668,60.805418],[-0.856018,60.836784],[-0.777483,60.830181],[-0.808378,60.757306],[-0.861442,60.723109],[-0.860263,60.674290],[-0.949882,60.674290],[-0.989032,60.719808],[-0.937854,60.776409],[-0.943986,60.812021],[-0.878187,60.844331],[-0.882668,60.805418]]],[[[-1.075821,60.730656],[-1.020870,60.726883],[-1.006955,60.637735],[-1.055774,60.642688],[-1.007899,60.565804],[-1.041152,60.499769],[-1.160252,60.487977],[-1.208835,60.605189],[-1.075821,60.730656]]],[[[-1.389960,60.396942],[-1.460712,60.417460],[-1.465665,60.488920],[-1.514955,60.465336],[-1.616603,60.473590],[-1.566369,60.542927],[-1.441137,60.569577],[-1.425100,60.615330],[-1.307888,60.621226],[-1.339254,60.583256],[-1.329585,60.450714],[-1.389960,60.396942]]],[[[-0.873470,60.566983],[-0.944222,60.629952],[-0.780785,60.613679],[-0.797529,60.570992],[-0.873470,60.566983]]],[[[-1.200816,59.973373],[-1.275813,59.98
@niahoo
niahoo / file_utils.erl
Created August 21, 2012 14:22 — forked from mrinalwadhwa/file_utils.erl
Erlang: list all the files in a directory and recursively in all its sub directories
-module(file_utils).
-export([recursively_list_dir/1,
recursively_list_dir/2]).
% @type name() = string() | atom() | binary().
-type name() :: string() | atom() | binary().