Skip to content

Instantly share code, notes, and snippets.

@mekuls
mekuls / get_coverage.py
Created January 14, 2016 00:43
A quick gist for a Codementor member
import re
the_text = """
<div class="marginbottom10">
<h3>Coverage</h3>
<p class="big:>
<span id='m_coverage' > 91.9%</span> </p>
<div>
"""
@mekuls
mekuls / S3PsBackup.ps1
Last active March 2, 2016 22:40
How to back stuff up to an S3 Bucket using AWS's Powershell cmdlets
Import-Module AWSPowershell
$access = "AKIXXXXXXXXXXQQ"
$private = "ktw3+XXXXXXXXXXXXXXXXXXXXXeyw"
$bucketName = "bucketname"
Set-AWSCredentials -AccessKey $access -SecretKey $private
$source = "D:\SomeFolder"
@mekuls
mekuls / MemoryStreamExample.cs
Created December 16, 2015 03:25
Basic Memory Stream Usage
// A little description of how reading and writing
// From a stream works.
[Test]
public void ReadWriteAssertions()
{
Stream theStream = new MemoryStream();
const string theWriteText = "foo ++ bar ++ baz";
var writer = new StreamWriter(theStream);
@mekuls
mekuls / Get-Diff.ps1
Last active December 8, 2015 22:24
How to MD5 Diff two files using Powershell
param (
[Parameter(Mandatory=$true)
[string]$File1,
[Parameter(Mandatory=$true)
[string]$File2
)
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
@mekuls
mekuls / UDPServer.cpp
Created December 7, 2015 05:43
A really simple C++ UDP socket gist written in C++
#include <sys/socket.h>
#include <stdio.h>
#include <asm/byteorder.h>
#include <string.h>
#include <cygwin/in.h>
class UDPServer {
public:
void Serve(int port, int bufferSize = 2048) {
@mekuls
mekuls / udpqos.js
Last active November 24, 2015 05:44
Basic UDP server
var dgram = require('dgram')
var theListeningPort = 50000;
var socket = dgram.createSocket('udp4');
socket.bind(theListeningPort, function() {
console.log("Binding on port " + theListeningPort + " successful");
});
@mekuls
mekuls / cwapi_contacts_example.py
Created November 6, 2015 00:06
Connectwise API GET request example
import base64
import json
import urllib.request
import urllib.parse
# Add a url reference for more information about this region string
region = "au"
# Add a url reference for more information about this release string
release = "v4_6_release"
# Add a url reference for more information about this 3.0 string
@mekuls
mekuls / New-ChoclateyMachine
Last active October 2, 2015 00:03
A build definition for the dev box that I use for most of my work
choco install git.install -y --force
choco install jdk8 -y
choco install 7zip -y
choco install jre8 -y
choco install nodejs.install -y
choco install sysinternals -y
choco install vlc -y
choco install skype -y
choco install filezilla -y
$LOOP_DELAY_SECONDS = 20
$SNAPIN_LIST = @(
"Microsoft.Exchange.Management.PowerShell.SnapIn",
"Microsoft.Exchange.Management.PowerShell.E2010",
"Microsoft.Exchange.Management.Powershell.Support",
"Microsoft.Exchange.Management.PowerShell.Setup")
# Email Preferences
$SMTP_SERVER = ""
$EMAIL_FROM_ADDRESS = "Microsoft Outlook <device.management@example.com>"
@mekuls
mekuls / puppet_agent_install.sh
Last active November 5, 2015 04:40
A bash script which will install and do basic configuration of a puppet agent
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "Error: This script must be run with root priviliges"
exit 1
fi
if [ -n "$1" ]; then
puppet_host=$1
else