Skip to content

Instantly share code, notes, and snippets.

@haeky
haeky / stuff
Last active August 29, 2015 14:01
alert('stuff');
@haeky
haeky / Pebble.rb
Last active August 29, 2015 14:00
Checking if the new Pebble Steel is out.
require 'nokogiri'
require 'watir'
require 'open-uri'
require 'pry'
class Tweetbot
def parse_website
browser = Watir::Browser.new :phantomjs
browser.goto('https://getpebble.com/checkout')
class Player
def play_turn(warrior)
if warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.feel.enemy?
warrior.attack!
elsif warrior.look.at(2).enemy?
warrior.shoot!
@haeky
haeky / program.bat
Created July 25, 2013 14:09
Check if a program is running in command line
tasklist /FI "IMAGENAME eq App.exe" 2>NUL | find /I /N "App.exe">NUL
if "%ERRORLEVEL%"=="0" echo Running !
@haeky
haeky / hex2string.cs
Created July 3, 2013 14:32
Example of a hex to string conversion and string to hex.
//DECODE -> HEX TO STRING
String wHexString = "THIS IS A CONVERSION TEST";
byte[] wRaw = new byte[wHexString.Length / 2];
for (int i = 0; i < wRaw.Length; i++)
{
wRaw[i] = Convert.ToByte(wHexString.Substring(i * 2, 2), 16);
}
String iStack = Encoding.ASCII.GetString(wRaw);
//ENCODE -> STRING TO HEX
@haeky
haeky / readerwriter.cs
Created June 27, 2013 15:23
Example of a StreamReader/StreamWriter in C# to modify a specific line.
using (StreamWriter wStreamWriter = new StreamWriter(wPathTarget))
{
using (StreamReader wStreamReader = new StreamReader(wPathSource))
{
while ((wLine = wStreamReader.ReadLine()) != null)
{
if (!wLine.Contains(iPackageName))
{
wStreamWriter.WriteLine(wLine);
}
@haeky
haeky / encryption.cs
Created June 17, 2013 14:34
Encrypt, decrypt and generate a key in C# using AES256.
#region Encryption
/// <summary>
/// Generate a private key
/// From : www.chapleau.info/blog/2011/01/06/usingsimplestringkeywithaes256encryptioninc.html
/// </summary>
private static string GenerateKey(int iKeySize)
{
RijndaelManaged aesEncryption = new RijndaelManaged();
aesEncryption.KeySize = iKeySize;
aesEncryption.BlockSize = 128;
@haeky
haeky / ajax_example.js
Last active December 18, 2015 03:58
Example Ajax from AltitudeHardware with Play! Framework 1.2.5
var actionDevices: #{jsAction @WebAPI.devices(":typeId")/},
$.ajax({
url: actionDevices({
typeId: id
}),
dataType: 'json',
success: function(result) {
$(".deviceList ul").empty();
$.each(result, function(i,value) {