Skip to content

Instantly share code, notes, and snippets.

@toopay
toopay / innocent.erl
Created December 27, 2014 17:44
"Hello world!"
%% HOWTO : Compile and run `innocent:hi()`
%% @see http://codegolf.stackexchange.com/questions/22533/weirdest-obfuscated-hello-world?newreg=44a2bf18dcc44f7dbdddc27caf1b4ceb
-module(innocent).
-export([hi/0]).
hi() -> erlang:apply(
list_to_atom(
[A || A <- [ Mua + Ha + Haa || <<Mua:8, Ha:8, Haa:8>> <= <<105:24>> ]]
++ [A || A <- [ Mua + Ha + Haa || <<Mua:8, Ha:8, Haa:8>> <= <<111:24>> ]]),
list_to_atom(
@toopay
toopay / innocent.erl
Last active August 29, 2015 14:12
"Hello world!" [1]
-module(innocent).
-export([hi/0]).
hi() -> io:format("Hello world!").
%% Analog with bellow :
%% hi() -> io:format(["H","e","l","l","o"," ","w","o","r","l","d","!"]).
@toopay
toopay / brewfactory.erl
Created January 2, 2015 07:01
Pint in concurrent
-module(brewfactory).
-export([pint/0]).
pint() ->
receive
{Pid, heinekken} ->
Pid ! "Dankjewel!",
pint();
{Pid, guiness} ->
Pid ! "Thank you!",
@toopay
toopay / worker.erl
Created January 2, 2015 07:43
Useless worker
-module(worker).
-export([do_the_useless_job/0]).
do_the_useless_job() ->
TimeStart = unixtime(),
G = fun(X) -> timer:sleep(100), io:format("~p~n", [X]) end,
[spawn(fun() -> G(X) end) || X <- lists:seq(1,10)],
io:format("All done in ~p microseconds~n", [unixtime()-TimeStart]).
unixtime() ->
@toopay
toopay / entity.erl
Created April 1, 2015 18:02
Riak injector
%% @doc Prepare map data
prepare_map(MapData) ->
%% The initial map to be expanded
InitialMap = riakc_map:new(),
%% Build tuple elem
Definition = element(2,MapData),
Data = [element(Nth, MapData) || Nth <- lists:seq(3,tuple_size(MapData))],
%% Fill in the data based by definition

Trustify Android App

Code Smell :

[master] : There are several major issues with this branch :

@toopay
toopay / index.html
Last active October 3, 2016 07:53
BixBox SDK Example
<html>
<head>
<title>SDK Test</title>
</head>
<body>
<div style="display:inline;"><bixbox:login onlogin="check" size="large"></bixbox:login></div>
<script>
function check() {
bixbox.check(function(response) {
statusCallback(response);
@toopay
toopay / project.py
Created March 1, 2017 08:10
PyGithub extension
"""
project.py
~~~~~~~~
Extending Github repo class to allow project access
:author: Taufan Aditya
"""
import github
@toopay
toopay / kongfig.md
Last active June 6, 2018 17:21
Kongfig and Kong Publisher Documentation

Overview

Kongfig allow declarative configuration. We can define our list of APIs and consumers in json/yaml and then run kongfig to ensure that our Kong is configured correctly. Kong Publisher is an interface that use Kongfig to allow us manage the upstream, build the routes and back-up the entire Kong data as snapshot.

Kongfig Schema

At the simplest form, your config.yml can be just :

---
  apis:
 -
@toopay
toopay / kongfig-schema.md
Last active September 1, 2020 09:44
Kongfig Schema

Overview

Kongfig allow declarative configuration. We can define our list of APIs and consumers in json/yaml and then run kongfig to ensure that our Kong is configured correctly. At the simplest form, your config.yml can be just :

---
  apis:
    -
 name: "mockbin"