Skip to content

Instantly share code, notes, and snippets.

@millsy
millsy / server.py
Last active April 16, 2019 06:25
Simple HTTP Server
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class S(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/json')
self.end_headers()
def do_GET(self):
self._set_headers()

Keybase proof

I hereby claim:

  • I am millsy on github.
  • I am millsy (https://keybase.io/millsy) on keybase.
  • I have a public key ASBcvryt7HEQQwOGWO8YmfWtAB8CNi8Pp8d_vjDAHxfQ1go

To claim this, I am signing this object:

---
- hosts: all
tasks:
- name : Set netdev_budget_usecs
sysctl:
name: net.core.netdev_budget_usecs
value: 5000
sysctl_set: yes
state: present
@millsy
millsy / gist:7007715
Created October 16, 2013 13:28
Batch file to check a files timestamp version and write the output to a new file (named using a timestamped file name)
@ echo off
setlocal EnableDelayedExpansion
set dd=%date% %Time%
set outputFile=C:\Output-Folder\%username%\TimestampChecker-%dd:~4,2%%dd:~7,2%%dd:~10,4%-%dd:~15,2%%dd:~18,2%%dd:~21,2%.txt
SET STUDIOFILE=C:\Folder-Name\FileName.dll
>%outputFile% 2>&1 (
@millsy
millsy / gist:7007633
Created October 16, 2013 13:22
Using OSDump to collect a set of logs/crash dumps and copy them to a network share
@ echo off
net use j: \\server-name\folder-name
cd /d "%PROGRAMFILES%\OpenSpan\OpenSpan Runtime Enterprise"
osdump.exe -osdir "%USERPROFILE%\My Documents\OpenSpan Studio for VS 2010" -mode hang
cd /d "%USERPROFILE%\My Documents\OpenSpan Studio for VS 2010"
@millsy
millsy / style.cs
Last active December 18, 2015 02:39
Remove window frame
public void StyleWindow(IntPtr handle)
{
Diagnostic.DebugInfo("StyleWindow() called");
int lStyle = GetWindowLong(handle, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
SetWindowLong(handle, GWL_STYLE, lStyle);
Diagnostic.DebugInfo("StyleWindow() ended");
}
@millsy
millsy / regex.cs
Created May 10, 2012 22:52
Regex Collection Matching Example Split Email in C#
public string[] emailSplit(string email)
{
string[] result = null;
Regex exp = new Regex(@"^([^@]*)@(.*)", RegexOptions.IgnoreCase);
MatchCollection matches = exp.Matches(email);
if (matches.Count == 1 && matches[0].Groups.Count > 1)
{
Match m = matches[0];
result = new string[m.Groups.Count -1];
for (int i = 1; i < m.Groups.Count; i++)
@millsy
millsy / fileurl.php
Created March 29, 2012 14:07
amazon s3 php get url of file
<?php
require_once 'sdk.class.php';
$s3 = new AmazonS3();
$s3url = $s3->get_object_url('mybucket', 'mypath/tofile.txt', '5 minutes');
echo $s3url;
?>
@millsy
millsy / p12.php
Created March 29, 2012 12:58
php asymmetric encryption/decryption using p12 file
<?php
$p12cert = array();
$file = 'https://myserver.com/myp12file.p12';
$c = file_get_contents($file);
if (openssl_pkcs12_read($c, $p12cert, '1234567890') )
{
$pkey = $p12cert['pkey']; //private key
@millsy
millsy / php-asym.php
Created March 28, 2012 14:30
php asymmetric encryption/decryption
<?php
echo "Source: $source";
$fp=fopen("/path/to/certificate.crt","r");
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
/*
* NOTE: Here you use the $pub_key value (converted, I guess)
*/
openssl_public_encrypt($source,$crypttext,$pub_key);