Skip to content

Instantly share code, notes, and snippets.

Parallel.For(0, H, y =>
{
int j = y * 3 * W;
//for(; y<ymax; ++y)
{
for (int x = 0; x < W; ++x)
{
float a = max,
b = max,
c = max;
from win32com.client import Dispatch
# Get a NetworkListManager object
networkListManager = Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")
print networkListManager.IsConnectedToInternet
colors = [
(0,0,0),
(150,75,0),
(255,0,0),
(255,165,0),
(255,255,0),
(154,205,50),
(100,149,237),
@shilrobot
shilrobot / ploss.py
Created July 17, 2012 22:50
simple UDP packet loss tester
"""
Usage:
(1) on host A:
python ploss.py recv <port>
(2) on host B:
python ploss.py send <A's hostname> <port from step 1>
(3) watch output on host B
"""
@shilrobot
shilrobot / hist.py
Created July 18, 2012 17:51
Display graphs of results from UDP packet loss tester
import matplotlib.pyplot as plt
from scipy import stats
import numpy as np
# parse CSV file
# format is <size>, <recv_time>, <send_time>
# recv_time and send_time may be on different clocks so we can only compare vs. mean
lines =[]
for l in open('client_data/0.csv'):
parts = [float(x) for x in l.strip().split(',')]
LUA:
-- prints "nil"
print(undefined_var)
AS3:
// doesn't even compile, gives you "Access of undefined property" compiler error.
trace(undefined_var);
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework.Content;
namespace Platformer
{
/// <summary>
@shilrobot
shilrobot / lcdtest.ino
Last active December 10, 2015 19:08
Arduino -> Adafruit 20x4 LCD (product ID 198): Test code, including optimized 4-bit or 8-bit LCD refresh routine.
#include <LiquidCrystal.h>
// Notes:
// - LCD has an on-board current limiting resistor for the LED backlight (510 ohm I think.)
// So it can be connected directly to +5V and GND.
// LCD backlight LED draws 34 mA.
// - The whole LCD only draws about 35-36 mA, so the backlight is the majority of the power.
// - The included contrast trim pot is 10K.
// - Line 1 wraps to line 3 and line 2 wraps to line 4, although LiquidCrystal::setCursor() works(!)
// So LCDWrite may require some adjustment...
@shilrobot
shilrobot / NordicTest.ino
Created February 5, 2013 07:16
Nordic Wireless nRF24L01+ test project (with two wireless modules connected to one Arduino.)
#include <SPI.h>
#define CE_0 2
#define CE_1 3
#define CS_0 4
#define CS_1 5
#define IRQ_0 6
#define IRQ_1 7
#define PIN_SS 10
@shilrobot
shilrobot / HexDumper.cs
Created April 28, 2013 03:41
C# hex dumper
using System.Text;
namespace Whatever
{
public static class HexDumper
{
public static string HexDump(byte[] data)
{
var sb = new StringBuilder();