Skip to content

Instantly share code, notes, and snippets.

View Zepheus's full-sized avatar

Cedric Van Goethem Zepheus

View GitHub Profile
/*!
* Cedric Van Goethem
* Rudimentary Twinkle Twinkle Little Star demo for
* http://wavepot.com/
*/
var transpose = 0.5;
var volume = 0.1;
var tempo = 2;
var notes = {'A': 440, 'B': 493.88, 'C': 523.25, 'D': 587.33, 'E': 659.25, 'F': 698.46, 'G': 783.99 };
@Zepheus
Zepheus / gist:11226757
Last active August 29, 2015 14:00
SMTP pool draft
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
using System.Threading;
namespace ConcurrentSMTP
@Zepheus
Zepheus / gist:8217359
Last active January 1, 2016 23:29
Small Shift-AND implementation. Allows wildcards. Works lowercase only with patterns up to 32 characters (uint32-bound, easily changed to 64-bit or bitvectors) http://en.wikipedia.org/wiki/Bitap_algorithm
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ShiftAnd
{
class Program
@Zepheus
Zepheus / gist:7826270
Created December 6, 2013 15:14
Prints the lines in a fancy table.
static void PrintFrame(string[] args)
{
var maxLen = args.Select(s => s.Trim().Length).Max();
for (var i = 0; i < maxLen + 4; ++i)
Console.Write("*");
Console.WriteLine();
var center = maxLen / 2;
foreach (var s in args)
{
@Zepheus
Zepheus / gist:7826234
Created December 6, 2013 15:12
Calculates Pi through Taylor expansion or Arctan.
static double Pi()
{
var value = 1d;
for (var i = 1; i < 10000; i++)
value += Math.Pow(-1d, i) * (1d / (2*i + 1));
return value * 4d;
}
@Zepheus
Zepheus / gist:7796422
Created December 4, 2013 22:03
Quick & dirty script C# script to fetch WLAN passwords without Admin rights.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Diagnostics;
namespace WlanPasswords
{
// Go-language square root implementation
package main
import ("fmt")
func Sqrt(x float64) float64 {
z, precision := 1.0, 2.22e-15
for {
z = (z + x/z)/2
if abs(z*z - x) < precision {
#!/bin/bash
echo '# Linux mod for RK3188 rooting script - Zepheus #'
echo 'Rooting device...'
adb shell mv /data/local/tmp /data/local/tmp.bak
adb shell ln -s /data /data/local/tmp
adb reboot
read -p "--- Reboot 1/3 - Press Space Bar once the device has rebooted"
adb shell rm /data/local.prop > nul
@Zepheus
Zepheus / gist:4563417
Last active December 11, 2015 06:59
A balanced binary search tree implementation using the red-black algorithm. This uses Haskell's pattern matching to rotate and balance the trees, which simplifies it a lot compared to the imperative style implementation.
-- Description: A red-black tree implementation in Haskell
-- Author: Cedric Van Goethem
-- Version 1.1, 2013
type Tree a = Node a
data Color = Red | Black deriving (Eq, Show)
data Node a = Node a Color (Node a) (Node a) | Nil deriving (Eq, Show)
tree :: (Ord a) => a -> Tree a
tree x = Node x Black Nil Nil
@Zepheus
Zepheus / gist:4493376
Created January 9, 2013 14:09
First implementation of Quadratic Probing HS. Hotspots: Comparisions with null. TODO: Allow primitives without a wrapper class.
/*
* HashSet.cs: A quadratic probing implementation of a HashSet
* Author: Cedric Van Goethem
* Revision: 1
*/
using System;
using System.Collections.Generic;
namespace DataStructures