Skip to content

Instantly share code, notes, and snippets.

@luuhq
luuhq / IsEven.cs
Created March 17, 2013 01:04
Shitty way of testing if a number is even
public bool IsEven(int num)
{
int up = num;
int down = num;
try
{
while(up != 0)
{
up = up + 2;
}
@luuhq
luuhq / main.py
Last active December 15, 2015 15:58
A two-line Wi-Fi SSID Sniffer in Python
from original import CallMe
CallMe()
@luuhq
luuhq / cdn-data.json
Created July 1, 2013 02:15
JSON data for the CDN index page
{
"formsoul": {
"url": "http://github.com/sluu99/formsoul",
"lastVersion": "0.0.1",
"allVersions": ["0.0.1"],
"cdn": "http://cdn.sluu99.com/formsoul/formsoul-<version>.min.js"
}
}
@luuhq
luuhq / fakenode.js
Last active December 19, 2015 04:38
Fakenode is a hack that can be used along with resolverjs (search on NPM) to allow a Javascript file running under NodeJS or in the browser
// sluu99 (C) 2013
// Released under WTFPL
// Fakenode version 0.0.1
window.require = function(x) {
if (x === 'resolverjs') {
return {
get: function(x, defaultVal) { return defaultVal; }
};
}
@luuhq
luuhq / concurrent-commits.txt
Last active August 29, 2015 13:59
Naive concurrent commits
void Commit(Row[] rows)
{
// yield priority to commits that came before
GetGlobalLock();
ReleaseGlobalLock();
// attempt to lock all rows
int i = 0;
for (i = 0; i < rows.Length; i++)
{
@luuhq
luuhq / SolarInfo.cs
Last active August 29, 2015 14:19 — forked from cstrahan/SolarInfo.cs
using System;
using System.Diagnostics;
namespace SunriseCalculator
{
public class SolarInfo
{
public double SolarDeclination { get; private set; }
public TimeSpan EquationOfTime { get; private set; }
public DateTime Sunrise { get; private set; }
@luuhq
luuhq / LineReader.cs
Last active August 29, 2015 14:25
LineReader.cs
/// <summary>
/// A stream reader which will puts the seek position to the right place after each line read.
/// </summary>
internal class LineReader
{
private Stream stream;
private Encoding encoding;
/// <summary>
/// Creates a new instance of this class.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Child1: {0}", new Child1().Caller);
Console.WriteLine("Child2: {0}", new Child2().Caller);
Console.WriteLine("Child3: {0}", new Child3().Caller);
}
public abstract class Parent
public Message Post([FromBody]Message message)
{
if (message.Type == "Message")
{
// calculate something for us to return
int length = (message.Text ?? string.Empty).Length;
// return our reply to the user
return message.CreateReplyMessage($"Hello from TallyBot! You sent {length} characters");
}
public class Command
{
public string Action { get; set; }
public string Parameters { get; set; }
public static bool TryParse(string text, out Command command)
{
command = null;