Skip to content

Instantly share code, notes, and snippets.

using System;
using System.IO;
using System.Net;
using MjpegCatcher.Properties;
using NCrontab;
namespace MjpegCatcher
{
class Program
{
@ah01
ah01 / ladder-export.txt
Created May 5, 2012 13:28
LDmicro, Arduino and PWM
LDmicro export text
for 'ANSI C Code', 4.000000 MHz crystal, 10.0 ms cycle time
LADDER DIAGRAM:
|| ||
|| ; Interier Light ||
1 || ; When you press the button (d2) led (pwm) will turn on and after some time (5 sec) fade out. ||
|| ||
@ah01
ah01 / gist:2553754
Created April 29, 2012 23:01
FireLogger UTF-8 test
<?php // this file is in utf-8
$json = '{"logs":[{"level":"debug","timestamp":1335428158.523,"message":"Žluťoučký kůň úpěl ďábelské ódy"}]}';
$res = str_split(base64_encode($json), 76);
foreach($res as $k=>$v) {
header("FireLogger-12345678-$k:$v");
}
// try content in different charset
@ah01
ah01 / example.php
Created March 16, 2012 00:18
PHP Thread class with exit code support
<?php
require "thread.php";
function doSomething($res, $t) {
usleep($t);
exit($res);
}
$thread1 = new Thread('doSomething');
@ah01
ah01 / gist:1654676
Created January 22, 2012 00:12
IsTime function
boolean IsTime(unsigned long *timeMark, unsigned long timeInterval) {
if (millis() - *timeMark >= timeInterval) {
*timeMark = millis();
return true;
}
return false;
}
@ah01
ah01 / gist:1032439
Created June 17, 2011 21:53
Extension Methods
using System;
// Co provede následující program?
//
// a) Vyvolá NullReferenceException
// b) Vypíše "true"
// c) Vypíše "false"
// d) To netuším, jsem Javista a tam Extension Metody nejsou :(
public static class TestProgram
@ah01
ah01 / gist:1030267
Created June 16, 2011 20:59
Show all links on page
javascript:var w = window.open("about:blank", "_blank");w.document.writeln("<pre>");for(var i = 0; i < document.links.length; i++) { var h = document.links[i].href; if (h.indexOf(location.host) < 0) w.document.writeln(h);};void(0);
@ah01
ah01 / assert.js
Created January 31, 2011 11:54
Tune Up jsFidler
(function () {
var output;
function getOutput () {
if (!output) {
output = document.body.appendChild(document.createElement("pre"));
}
return output;
}
@ah01
ah01 / gist:762576
Last active April 29, 2021 14:10
const.pde
//
// This sketch will print some of interesting predefined constants to Serial.
//
// For more information, look at
// http://electronics4dogs.blogspot.com/2011/01/arduino-predefined-constants.html
// helper macro
#define LINE(name,val) Serial.print(name); Serial.print("\t"); Serial.println(val);
void setup()
@ah01
ah01 / gist:564636
Created September 3, 2010 21:56
Generate yUML class diagram for all Exception classes in PHP
<?php
foreach (get_declared_classes() as $class)
{
if(is_subclass_of($class, "Exception"))
{
$parent = get_parent_class($class);
$color = in_array($class, spl_classes()) ? "{bg:lightblue}" : "";
echo "[$parent]^-[$class$color]\n";