Skip to content

Instantly share code, notes, and snippets.

View emiflake's full-sized avatar
🌼
Petaline enjoyer

emiflake

🌼
Petaline enjoyer
  • Liqwid Labs
  • Amsterdam, The Netherlands
  • 14:23 (UTC +01:00)
View GitHub Profile
class Fraction
@top
@bot
# top is the x in (x/n)
# bot is the n in (x/n)
def initialize top, bot
@top = top
@emiflake
emiflake / JavaScript
Created December 21, 2016 16:54
Talkomatic Utils
String.prototype.shuffle = function () {
var a = this.split(""),
n = a.length;
for(var i = n - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
@emiflake
emiflake / utils.js
Created December 21, 2016 16:54
Some talkomatic utils
String.prototype.shuffle = function () {
var a = this.split(""),
n = a.length;
for(var i = n - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
template <class T>
class EventHandler
{
vector<void(*)(Event<T>&)> subs;
public:
EventHandler::EventHandler();
void EventHandler::subscribe(void(*handler)(Event<T>&));
void EventHandler::emit(Event<T> value);
};
@emiflake
emiflake / iceverything.ts
Last active April 25, 2017 18:02
I See Everything
import Discord = require("discord.js")
import fs = require("fs");
import path = require("path");
namespace ISeeEverything {
enum LogType {
MESSAGE_SENT,
MESSAGE_EDITED,
MESSAGE_DELETED,
USER_JOINED,
@emiflake
emiflake / index.js
Last active February 8, 2019 20:22
Discord downloader
const Discord = require('discord.js');
const R = require('ramda');
const bot = new Discord.Client();
const request = require('request');
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const prog = require("commander");
sudo apt-get remove abiword abiword-common abiword-plugin-grammar abiword-plugin-mathview alacarte bison blueman brltty-x11 catfish espeak exo-utils flex fonts-droid fonts-lyx gcalctool gigolo gimp gimp-data gksu gmusicbrowser gnome-desktop-data gnome-system-tools gnome-time-admin gnumeric gnumeric-common gnumeric-doc gstreamer0.10-gnomevfs gthumb gthumb-data gtk2-engines-pixbuf indicator-application-gtk2 indicator-sound-gtk2 libabiword-2.9 libamd2.2.0 libbabl-0.1-0 libbison-dev libblas3 libcolamd2.7.1 libdigest-crc-perl libexo-1-0 libexo-common libexo-helpers libfl-dev libgarcon-1-0 libgarcon-common libgdome2-0 libgdome2-cpp-smart0c2a libgegl-0.2-0 libgimp2.0 libgksu2-0 libglade2-0 libgnomevfs2-0 libgnomevfs2-common libgnomevfs2-extra libgoffice-0.10-10 libgoffice-0.10-10-common libgsf-1-114 libgsf-1-common libgstreamer-perl libgtk2-notify-perl libgtk2-trayicon-perl libgtkmathview0c2a libgtksourceview2.0-0 libgtksourceview2.0-common libgtkspell0 libido-0.1-0 libintl-perl libjavascriptcoregtk-1.0-0 libjpeg-pr
@emiflake
emiflake / maybe.ts
Created September 17, 2018 15:23
Monadic Maybes using Promises! (In TypeScript)
interface Maybe<T> {
isJust: Boolean;
isNothing: Boolean;
}
class Just<T> implements Maybe<T> {
constructor(private value: T) {
}
isJust: true;
isNothing: false;
@emiflake
emiflake / Main.hs
Created October 1, 2018 11:34
JSON Parser in Haskell, more or less compliant
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.HTTP
import Data.Attoparsec.ByteString.Char8
import Data.Attoparsec.Combinator
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C8
import Data.Word
import Control.Applicative
function concat_map(array $arr, callable $f): array {
return array_reduce(array_map(function($k, $v) use ($f) {
return $f($k, $v);
}, array_keys($arr), $arr), function($acc, $v) {
return array_merge($acc, $v);
}, []);
}