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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@rbrick
rbrick / merge.go
Created June 19, 2016 06:14
Merges multiple slices into one without duplicates.
// Merges slices into one without duplicates
func merge(slices... []string) []string {
merged := *new([]string)
// Use a map for faster lookup
contains := map[string]bool{}
for _, v := range slices {
for _, s := range v {
if _, ok := contains[s]; ok {
// already contains. Skip!
function copy(text) {
// create the element
var copy_from = document.createElement('textarea');
copy_from.style.position = 'absolute';
copy_from.setAttribute('readonly', '');
copy_from.value = text;
// add to body
document.body.appendChild(copy_from);

Keybase proof

I hereby claim:

  • I am rbrick on github.
  • I am rbrick (https://keybase.io/rbrick) on keybase.
  • I have a public key ASCEy5b7PX-m9B77Dj9mHOrs5R2Ne8V_jkDH8XbnTjnARgo

To claim this, I am signing this object:

@rbrick
rbrick / login.py
Created July 12, 2016 05:41
Old login system made in Python
import json
import os
import sqlite3
from flask import Flask, render_template, request, flash, session, redirect, url_for
from werkzeug import security
app = Flask(__name__)
app.secret_key = os.urandom(32)
conn = sqlite3.connect('database.db')
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CURSE_ARRAY_SIZE 5
#define CURSE_AMOUNT 100
char* CURSE_WORDS[] = { "SHIT", "FUCK", "DAMN", "DAMMIT", "CRAP" };
void main()
@rbrick
rbrick / yggdrasil.go
Created September 7, 2016 08:43
Simple implementation of Yggdrasil (Mojang's authentication service)
// This is a client implementation of Yggdrasil (Mojang's authentication server used for their games.)
// Big thanks for documentation provided by http://wiki.vg/Authentication
package main
import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"log"
import java.util.concurrent.TimeUnit;
public final class TestClass {
public static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"In in pellentesque sem, quis iaculis sapien. Quisque ut velit vel ex facilisis euismod in et " +
"neque. Donec eget ex in nisl dapibus congue id ultricies odio. Nulla et nibh nec nunc pretium aliquet " +
"in quis augue. Aenean sit amet nisi eu tortor malesuada tincidunt. Fusce in pulvinar sapien, vitae mollis orci. " +
"Donec sed purus luctus, convallis metus sit amet, volutpat turpis. Sed quis nunc id nisl fringilla tincidunt a ut urna.";
@rbrick
rbrick / OTP.kt
Last active November 6, 2018 06:48
HOTP/TOTP code generation implementation in Kotlin
import java.nio.ByteBuffer
import java.time.Instant
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
interface Counter {
fun count(): Long
}
class BasicCounter(var x: Long) : Counter {
@rbrick
rbrick / solutions.cs
Created November 15, 2018 01:39
edabit.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
public class Program
{
static char[] VOWELS = new char[] { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' };