Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / 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 / 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 / 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 / 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 / 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 / index.html
Last active October 11, 2015 10:38
Example of a page embedding shawty
<script>
function shawty(data) {
if (data.success) {
document.write(
'<a href="' + data.short +
'">Short URL to the current page</a>');
}
}
</script>
<script src="//luu.bz/shawty.js"></script>
@luuhq
luuhq / shawty.js
Last active October 11, 2015 10:38
A shawty callback example
shawty({
'success': 1,
'message': '',
'short': 'http://luu.bz/bD',
'long': 'http://en.wikipedia.org/wiki/URL_shortening',
'hits': 0,
'timestamp': 1349564105
});
@luuhq
luuhq / GoogleDoodleBasketball2012.java
Created August 8, 2012 17:24
Java code to play google doodle for you
Robot r = new Robot();
System.out.println("Start!");
Thread.sleep(2000); // give yourself some margin to switch window
int[] times = { 1, 5, 4, 4, 1, 3, 2 }; // number of shots for each distance
int[] delays = { 400, 400, 575, 820, 850, 1150, 1350 }; // time holding the ball
int[] delays2 = { 200, 650, 700, 600, 400, 450, 400 }; // time waiting for a new ball
for (int i = 0; i < times.length; i++)
for (int j = 0; j < times[i]; j++) {
r.keyPress(KeyEvent.VK_SPACE);
r.delay(delays[i]);