Skip to content

Instantly share code, notes, and snippets.

View corytodd's full-sized avatar

Cory Todd corytodd

View GitHub Profile
internal static string Decrypt(byte[] key,string input)
{
if (input == null || input.Length <= 0)
throw new ArgumentNullException("input");
if (key == null || key.Length <= 0)
throw new ArgumentNullException("Key");
var un64byte = Convert.FromBase64String(input);
if (un64byte.Length < 16)
return ""; // Too short
using System;
using System.IO.Ports;
class PortDataReceived
{
public static void Main()
{
SerialPort portA = new SerialPort("COM7");
@corytodd
corytodd / gist:11165166
Created April 22, 2014 04:14
Unit Test Async
/// <summary>
///A test for calibrate wifi
///</summary>
[TestMethod()]
public void CalibrateWifi_Test()
{
ICommDevice target = CTalk.Calibrate();
Action<byte> callback = new Action<byte>((byte b) => Assert.IsTrue(b == (byte)CTalkCommand.Code.ACK));
PTalk.CalibrateWifitarget, callback);
}
@corytodd
corytodd / gist:77d4169839b4902e8cbc
Created November 22, 2014 19:42
Test MS Virtual Serial Port driver sample
using System;
using System.IO.Ports;
namespace VCPTest
{
class Program
{
static bool _continue;
static SerialPort _serialPort;
@corytodd
corytodd / CodeGolf_NotLogic.nim
Last active August 29, 2015 14:18
Version with some breathing room...
proc s(x, y, b: var int)=
x = x div 2
y = y div 2
b *= 2
proc n(x: var int): int =
return -(x+1)
proc a(x, y: var int): int =
var b = 1
@corytodd
corytodd / bitbucket_team_repos.py
Created August 9, 2015 17:56
Python Bitbucket helper
from rauth import OAuth1Service
import BaseHTTPServer
import threading,time
import webbrowser
import urlparse
class Config(object):
def __init__(self):
# Create a new consumer at https://bitbucket.org/account/user/{username}/api
self.consumer_key = <YOUR_KEY>
http://stackoverflow.com/questions/9023129/algorithm-for-bit-expansion-duplication
We are isolating each nibble, then each bit per the expansion factor (3 in this case)
out = (in | in << 8) & 0x0F00F;
out = (out | out << 4) & 0x0C30C3;
out = (out | out << 2) & 0x249249;
out *= 7;
== 0000 0000 0000 0000 1101 0101 (in == 0xD5)
#!/bin/sh
# Makefile fixer
# Some old projects that have been touched by dumb text editors
# may have had their makefile tabs turned in spaces. For large
# projects, this is a pia to fix. Use this script in your project
# directory as a quick fix. +1 for the expand command.
set -e
old="$1"
@corytodd
corytodd / sign_published.py
Last active June 13, 2018 02:58
ClickOnce SHA256 Signing outside of Visual Studio
from xml.dom import minidom
from subprocess import check_output
#Set this to the Visual Studio output directory, no trailing \
path = 'X:\absolute\path\tp\publish\directory'
#Typically found as MyApp.application in the publish directory
app = "MyApp"
#Path to Mage.exe. Notice the delimented \v
mage = '"C:\Program Files (x86)\Microsoft SDKs\Windows\\v7.0A\Bin\mage.exe"'
@corytodd
corytodd / TwoSidedImagePane.Java
Created June 13, 2018 02:58
JavaFX two-sided image widget
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.geometry.Point3D;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.transform.Rotate;
import javafx.util.Duration;