Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@msabramo
msabramo / get-serial-number.exp
Created September 30, 2017 16:01
Script to get the serial number of a Mac OS computer
#!/usr/bin/expect -f
#
# Script to get the serial number of a Mac
#
set timeout 10
log_user 0
spawn /bin/sh -c "ioreg -rac IOPlatformExpertDevice | xpath 'plist/array/dict/key\[.=\"IOPlatformSerialNumber\"\]/following-sibling::*\[position()=1\]/text()' 2>/dev/null"
expect eof
set serial $expect_out(buffer)
puts $serial
@msabramo
msabramo / keybase.md
Created July 8, 2016 20:33
Proving my identity for keybase.io

Keybase proof

I hereby claim:

  • I am msabramo on github.
  • I am msabramo (https://keybase.io/msabramo) on keybase.
  • I have a public key ASAlHNkORhOLjfgneM_MPvQgkgP-7nodqWEmFfgrpL85tQo

To claim this, I am signing this object:

@msabramo
msabramo / mock_patch_multiple_targets.py
Created September 11, 2015 19:42
Mock patch multiple targets in Python
@contextlib.contextmanager
def multiple_targets(mock_patches):
"""
`mock_patches` is a list (or iterable) of mock.patch objects
Example usage:
with mock.patch.multiple_targets([
mock.patch('os.path.exists', side_effect=mock_path_exists),
mock.patch('subprocess.Popen'),
@msabramo
msabramo / multiple_mocks.py
Created September 11, 2015 16:12
A Python context manager for doing multiple mock.patches
@contextlib.contextmanager
def multiple_mocks(mock_specs):
"""
`mock_specs` is a dict of mock target name => mock patch kwargs
Example usage:
with multiple_mocks(
{'os.path.exists': {'side_effect': mock_path_exists},
'subprocess.Popen': {},
@msabramo
msabramo / Instructions.md
Last active August 29, 2015 14:25 — forked from dtrapezoid/Instructions.md
Becoming Friends with Cassandra Workshop Instructions

Instructions for "Becoming Friends with Cassandra"

Go here:

https://gitter.im/DataStaxCommunity/Cassandra_Spark

Where do I start?

To start communicating with Cassandra like a champ, Cassandra's Query Language (CQL) is your best bet. CQL is an SQL-like language, which makes it warm and fuzzy for those of us used to SQL, but don't let that fool you...

We still have to think about how we "converse" with Cassandra differently. When we model our data, we need to think about how we will access it before we model it. It's important to emphasize this point, because you can get into some very ugly territory if you model Cassandra like a relational database. Data Modeling with Cassandra is purely query-driven.

@msabramo
msabramo / human_log.py
Last active September 11, 2015 19:30 — forked from cliffano/human_log.py
import os
FIELDS = os.environ.get('ANSIBLE_HUMAN_LOG_FIELDS').split(',')
if not FIELDS:
FIELDS = ['cmd', 'command', 'start', 'end', 'delta', 'msg', 'stdout', 'stderr']
def human_log(res):
if type(res) == type(dict()):
for field in FIELDS:
@msabramo
msabramo / gist:05ca407f20c36da2c133
Created June 9, 2015 15:27
FreeTDS 0.95 ChangeLog
Finally, after years of improvements and fixes we got a new version
Summary of Changes in release 0.95
--------------------------------------------
User visible (not in a particular order):
- Support for build with CMake under Windows.
- Support MSSQL 2008:
- new date/time types;
- NBCROWs;
- able to retrieve CLR UDT types in binary format.
@msabramo
msabramo / output.txt
Last active August 29, 2015 14:20
Tox keeps executing commands even when one fails
$ tox --version
1.9.0 imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tox/__init__.pyc
$ tox
py27 runtests: PYTHONHASHSEED='1229193552'
py27 runtests: commands[0] | echo 1
1
py27 runtests: commands[1] | false
ERROR: InvocationError: '/usr/bin/false'
py27 runtests: commands[2] | echo 2
@msabramo
msabramo / gist:d3b7bc49b1f2414e372d
Created March 27, 2015 14:53
Error installing MsSqlServer2012Express on Hyper-V Server with Chocolatey
C:\Program Files\Microsoft SQL Server\110>choco install -y mssqlserver2012express
Chocolatey (v0.9.8.33) is installing 'mssqlserver2012express' and dependencies.
By installing you accept the license for 'mssqlserver2012express' and each dependency you are installing.
MsSqlServer2012Express v11.00.3000.20140928
Downloading SqlServer2012Express 64 bit
from 'http://download.microsoft.com/download/5/2/9/529FEF7B-2EFB-439E-A2D1-A1533227CD69/SQLEXPRWT_x64_ENU.exe'
Installing SqlServer2012Express...
Write-Error : [ERROR] Running C:\Users\ADMINI~1\AppData\Local\Temp\1\chocolatey
\SqlServer2012Express\SqlServer2012ExpressInstall.exe with /q /INDICATEPROGRESS
@msabramo
msabramo / gist:d983f597ea20d261ff2f
Created February 9, 2015 18:34
freezegun pypy test failures
======================================================================
ERROR: tests.test_class_import.test_start_and_stop_works
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/marca/dev/git-repos/freezegun/.tox/pypy3/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/Users/marca/dev/git-repos/freezegun/tests/test_class_import.py", line 37, in test_start_and_stop_works
freezer = freeze_time("2012-01-14")
File "/Users/marca/dev/git-repos/freezegun/freezegun/api.py", line 366, in freeze_time
return _freeze_time(time_to_freeze, tz_offset, ignore)