Skip to content

Instantly share code, notes, and snippets.

@motleytech
motleytech / verbalArith.py
Last active June 16, 2023 18:52
Verbal arithmetic
from pprint import pprint as pp
from time import time
st = time()
def codeForGuess(ch, firsts, indent):
ind = ' '*indent
v1 = """\
%sfor %s in %s:
%s urem(%s)""" % (ind, ch, "udiff(set0)" if ch in firsts else "ucopy()",
@motleytech
motleytech / osx_vm.md
Created June 25, 2016 05:36
osx vm on osx

Recently, I tried creating an OSX Virtualbox VM on my macbook. Creating a virtualbox VM should be easy, I guessed, as I am just looking to run an OSX guest on an OSX host. Not trying to create a hackintosh here.

However, it turned out to be more tricky than I anticipated. For starters, I needed a bootable iso of the OSX operating system, but Apple does not provide one anymore. So this is what I had to do...

I searched around on google and ran into many useless pages. Finally, I found one that had a useful solution.

I replicate the instructions here, in case that website goes missing.

Step by step instructions

Look for Install OSX Yosemite.app in your /Applications folder. If its already there, you can save on a large download.

{
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"jsxBracketSameLine": true
}
@motleytech
motleytech / casper.md
Created June 21, 2016 01:00
Deal with casper

Unofficial Guide to JAMF Casper

This page documents the external/internal behavior of Casper.

Files

Casper installed itself into the following directories:

  • /Library/Application Support/JAMF
    • ManagementFrameworkScripts - a set of scripts that runs on certain events
      • StartupScript.sh - Activated when jamf is started
      • loginhook.sh - Activated when user login
  • logouthook.sh - Activated when user logout
@motleytech
motleytech / autoreload for twisted reactor
Created April 22, 2016 20:16
Autoreload for twisted server
#
# usage:
#
# import autoreload
#
# def myMain():
# site = server.Site(root)
# reactor.listenTCP(8080, site)
# reactor.run()
#
@motleytech
motleytech / runCmdAndGetOutput.py
Created April 13, 2016 23:37
Python snippet to run external command and get output
import subprocess
def runCommandAndGetOuput(command):
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
(stdoutdata, stderrdata) = proc.communicate()
return stdoutdata
@motleytech
motleytech / circleChords.html
Created September 20, 2019 05:52
Geometric fun part 1 - chords in a circle
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Draw a line</title>
<style>
#DemoCanvas {
border: 1px solid #ddd;
}
</style>
@motleytech
motleytech / local smtp mail server in python
Created April 28, 2016 22:02
Running a local smtp mail server in Python
python -m smtpd -n -c DebuggingServer localhost:25
@motleytech
motleytech / revMouseScroll3.py
Last active January 14, 2019 18:23
Python 3 Script to edit Registry for reversing mouse scroll direction
from winreg import *
import os
def is_admin():
if os.name == 'nt':
try:
# only windows users with admin privileges can read the C:\windows\temp
temp = os.listdir(os.sep.join([os.environ.get('SystemRoot','C:\\windows'),'temp']))
except:
return False
@motleytech
motleytech / pysync2.py
Created December 5, 2018 22:51
Rsync like functionality using python distutils.dir_util.copy_tree
import sys
import distutils.log
import distutils.dir_util
import os
if len(sys.argv) != 3:
print ('Usage : python pysync2.py src dest')
exit(1)
src, dest = map(os.path.abspath, sys.argv[1:])