Skip to content

Instantly share code, notes, and snippets.

@rob-smallshire
rob-smallshire / macOS-in-virtualbox.md
Last active April 3, 2024 19:03
Notes on getting macOS Sierra running in Virtualbox on a Windows 10 host

On Mac

Download, but don't run, the Sierra installer from the Mac App Store. This places the installer at /Applications/Install\ macOS\ Sierra.app/.

Now run the following commands to build a suitable VM image from the installer:

git clone https://github.com/jonanh/osx-vm-templates
cd osx-vm-templates/packer

sudo ../prepare_iso/prepare_vdi.sh -D DISABLE_REMOTE_MANAGEMENT -o macOS_10.12.vdi /Applications/Install\ macOS\ Sierra.app/ .

@dbf256
dbf256 / event_timer.py
Last active October 21, 2016 02:30
Event timer - simple time tracing for Python
import datetime
class EventTimer:
def __init__(self, name):
self.events = []
self.timer = None
self.name = name
def reset(self):
@stoneage7
stoneage7 / VDI-shrink-trim.md
Last active February 20, 2024 21:00
Automatically shrinking VDI images under VirtualBox

Motivation

The purpose of this gist is to set up a virtual machine in such a way that the on-disk image in the host machine automatically grows and shrinks as needed by the guest machine. This utilizes the (still undocumented) "--discard" and "--nonrotational" parameters in "VBoxManage storageattach" which make the attached image appear as an SSD to the guest. Guest OS will then issue TRIM commands to the virtual controller where such an image is attached. VirtualBox is then able to capture the commands and punch holes in the attached VDIs.

Although there is some initial setup needed, I think the time saved with babysitting the VDIs is worth it. Usually you would need to zero out the free space with zerofree or sdelete and then run "VBoxManage --compact" on your images. With this setup you can allocate a large dynamic VDI (1TB or so) and it will keep itself at minimum size for easy syncing, backup, etc. You can also set it up in a template machine if you use one for clones etc.

Requirements

  • Linux
@mrkline
mrkline / c_sharp_for_python.md
Last active March 9, 2024 20:09
An intro to C# for a Python developer. Made for one of my coworkers.

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

@jessicald
jessicald / gist:2861038
Created June 3, 2012 02:34
Class vs. Dictionary; or, An Example of Space-Time Tradeoff

Class vs. Dictionary; or, An Example of Space–Time Tradeoff in Python

Conclusions; or, tl;dr

What wins?

  • struct-like objects, i.e. ones that are largely the same as a C struct instance, win in the memory department.
    • These tests do not try to determine what is best for very large sets of values, however; I direct the reader to http://stackoverflow.com/a/2670191 for an insight into that scenario when using a dictionary.
  • Dictionaries beat out objects in access times.
  • According to Wikipedia, the Python dictionary is highly optimised because it is used internally to implement namespaces. [citation needed]
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream