Skip to content

Instantly share code, notes, and snippets.

@piccaso
piccaso / ssh.cs
Last active December 7, 2022 07:07
ssh.net Example - Keybased Authentication, File Upload, Shell Commands
/*
get SSH.NET (BSD License: http://sshnet.codeplex.com/license)
with NuGet:
>Install-Package SSH.NET -Version 2013.4.7
or just get the dll from here: http://j.mp/sshNet
*/
using System;
#! /bin/sh -e
### BEGIN INIT INFO
# Provides: compasswatcher
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the compass watch process for each directory
### END INIT INFO
<?php
function preg_extract($pattern,$subject,$n=1,$default=''){
if(preg_match($pattern, $subject, $m)){
if (isset($m[$n])) return $m[$n];
}
return $default;
}
@piccaso
piccaso / gist:4179759
Created December 1, 2012 00:30
win32 GetLastInputInfo C# example
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace GetLastUserInput
{
public class GetLastUserInput
{
private struct LASTINPUTINFO
{
@piccaso
piccaso / main.cs
Created October 13, 2012 23:01
regex 'reduce path' & y/n question
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
//using Sharpduino;
//using Sharpduino.Constants;
namespace ConsoleApplication1
{
@piccaso
piccaso / lcd_example.c
Created May 5, 2012 16:44
LCD example using new-liquidcrystal with a ciruit from 3g1l.com.
#include <LiquidCrystal_SR.h>
LiquidCrystal_SR lcd(8,7,TWO_WIRE);
// | |
// | \-- Clock Pin
// \---- Data/Enable Pin
// Creat a set of new characters
byte armsUp[8] = {
0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010};
@piccaso
piccaso / gist:2603879
Created May 5, 2012 16:37
parsing dd.mm.yyyy hh:ss (tt.mm.jjjj ss:mm) date (used in austria)
<?php
function parse_austrian_date($date,$output='U'){
$date = DateTime::createFromFormat('d.m.Y H:i', $date);
if($date === false) return false;
return $date->format($output);
}
echo parse_austrian_date('1.2.12 24:14','d.m.Y H:i:s');