Skip to content

Instantly share code, notes, and snippets.

@msmorul
msmorul / lync-sample1.py
Created December 10, 2013 23:31
Example python script for authenticating to Lync and creating an application endpoint that lists all of a persons contacts. Python example for what's described here https://ucwa.lync.com/documentation/keytasks-createapplication
import requests
import json
from urlparse import urlparse
sip_domain = "SIP_DOMAIN.COM"
username = "USERNAME@SIP_DOMAIN.COM"
password = "YOUR_LYNC_PASSWORD"
def extractAuthURL(str):
start = str.find('MsRtcOAuth');
@msmorul
msmorul / sid-convert.py
Created April 23, 2014 14:23
convert windows sid to uid for centrify express
#!/usr/bin/python
#
# Convert windows sid to centrify express generated uid
# http://community.centrify.com/t5/DirectControl-Express-for-UNIX/RE-Evaluating-Centrify-Express-Now-And-Have-Some-Questions/td-p/3174
import argparse
import re
def sid(value):
sidrx = re.compile('^S-1-5-\d{2}-\d+-(\d{4,10})-\d+-(\d+)$')
m = sidrx.match(value)
@msmorul
msmorul / class.smbAccessDriver.php.class
Created October 23, 2014 15:33
patch for fixing zipping files over the smb driver in pyd.io
--- class.smbAccessDriver.php.orig 2014-10-23 11:15:47.699206429 -0400
+++ class.smbAccessDriver.php 2014-10-23 11:21:50.423194343 -0400
@@ -86,16 +86,33 @@
require_once(AJXP_BIN_FOLDER."/pclzip.lib.php");
$filePaths = array();
foreach ($src as $item) {
- $realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase.(($item[0] == "/")? "" : "/").AJXP_Utils::securePath($item));
- $basedir = trim(dirname($realFile))."/";
- $filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile,
- PCLZIP_ATT_FILE_NEW_SHORT_NAME => basename($item));
// based on the grid from: http://knockoutjs.com/examples/resources/knockout.simpleGrid.3.0.js
// configuration: columns: {headerText, rowText (fn or property name,) headerClass, cellTemplate}
(function () {
// Private function
function getColumnsForScaffolding(data) {
if ((typeof data.length !== 'number') || data.length === 0) {
return [];
}
var columns = [];
for (var propertyName in data[0]) {
#
# Print a summary of disk usage in the supplied directory
# -directory <directory>
#
Param(
[parameter(Mandatory=$true)]
[alias("d")]
$directory
)
@msmorul
msmorul / halloween.py
Last active October 31, 2015 20:21
Quick hack to have an HC-sr04 play an mp3 or a scary sound when something comes near.
import RPi.GPIO as GPIO
import time
from pygame import mixer
import random
GPIO.setmode(GPIO.BCM)
TRIG = 23
ECHO = 24
#
# background music
@msmorul
msmorul / create-uid.ps1
Created November 5, 2015 17:06
Example script showing how to create the aut-generated unix uid for centrify
param (
[string]$username = $(throw "-username is required.")
)
#
# Load Account Details
#
$user = Get-ADObject -Filter {(sAMAccountName -eq $username)} -Properties 'ObjectSID','uidNumber'
$sidStr = $user.ObjectSID
"Found ObjectSID: {0} for {1}" -f $sidStr,$username
#
@msmorul
msmorul / main.c
Created November 12, 2015 17:16
serial boot loader for a pic12f1822
/*
* File: main.c
* Author: toaster
*
* Created on November 5, 2015, 8:45 PM
*/
#include <xc.h> /* XC8 General Include File */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
function getMonday {
$days="Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
return (Get-Date).AddDays(-([array]::IndexOf($days,(Get-Date).DayOfWeek.ToString())-1))
}
$user = "NT User:S-1-5-21-579602563-1105609867-1454996784-1641"
$mailbox = "[email protected]"
$folders = @(Get-MailboxFolderStatistics $mailbox | Where {!($exclusions -icontains $_.FolderPath)} | Select FolderPath)
foreach ($origFolder in $folders) {
$id = $mailbox + ":" + $origFolder.FolderPath.Replace('/','\')
# Uncomment this to list all unattached sids
# get-MailboxFolderPermission -Identity $id | where {$_.user -like "*S-1-5*"}
# Remove dead permissions
if ($perm = get-MailboxFolderPermission -Identity $id -user $user -ErrorAction SilentlyContinue) {
remove-MailboxFolderPermission -Identity $id -user $user -Confirm:$false -ErrorAction STOP