Skip to content

Instantly share code, notes, and snippets.

@richard-scott
richard-scott / time-function.ps1
Created June 14, 2018 20:24 — forked from bender-the-greatest/time-function.ps1
Alternative implementation of Measure-Command, works similarly to Linux `time` command
# Alternative (improved?) implementation of Measure-Command
# Works similarly to the Linux/Unix `time` command
#
# Function which times how long a command takes to completion
# Note that this function outputs to Write-Host so as to
# protect the proper return value. Note that a time will be
# returned even if the command fails.
#
# Unless `-quiet` is specified, command output is sent directly
# to `Write-Host` to allow for the simultaneous return of the
@richard-scott
richard-scott / hack.sh
Created June 25, 2018 14:14 — forked from garethrees/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2470157/hack.sh | sh
#
@richard-scott
richard-scott / macOS-in-virtualbox.md
Created June 29, 2018 09:19 — forked from rob-smallshire/macOS-in-virtualbox.md
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/ .

@richard-scott
richard-scott / create-iso.sh
Created July 4, 2018 09:11 — forked from julianxhokaxhiu/create-iso.sh
Simple bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
#!/bin/bash
#
# Credits to fuckbecauseican5 from https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/
# Adapted to work with the official image available into Mac App Store
#
# Enjoy!
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
@richard-scott
richard-scott / highsierra_bootable.sh
Last active July 4, 2018 09:20 — forked from agentsim/highsierra_bootable.sh
Create bootable ISO from HighSierra Installer
# Generate a BaseSystem.dmg with 10.13 Install Packages
hdiutil attach /Applications/Install\ macOS\ High\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -mountpoint /Volumes/highsierra
hdiutil create -o /tmp/HighSierraBase.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/HighSierraBase.cdr.dmg -noverify -mountpoint /Volumes/install_build
asr restore -source /Applications/Install\ macOS\ High\ Sierra.app/Contents/SharedSupport/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -R /Volumes/highsierra/Packages /Volumes/OS\ X\ Base\ System/System/Installation
hdiutil detach /Volumes/OS\ X\ Base\ System/
hdiutil detach /Volumes/highsierra/
mv /tmp/HighSierraBase.cdr.dmg /tmp/BaseSystem.dmg
@richard-scott
richard-scott / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Created September 26, 2018 11:14 — forked from whizzzkid/XPS-15 9560 Getting Nvidia To Work on KDE Neon
[XPS 15 Early 2017 9560 kabylake] Making Nvidia Drivers + (CUDA 8 / CUDA 9 / CUDA 9.1) + Bumblebee work together on linux ( Ubuntu / KDE Neon / Linux Mint / debian )
# Instructions for 4.14 and cuda 9.1
# If upgrading from 4.13 and cuda 9.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-9.0/
# Important libs required with 4.14.x with Cuda 9.X
$ sudo apt install libelf1 libelf-dev
@richard-scott
richard-scott / Download GitHub Repos for KiCad
Last active November 22, 2018 13:42
Download GitHub Repos for KiCad
Installation
------------
1. Create a KiCad folder somewhere on your system, and then create a shortcut to that folder in your $HOME folder.
2. Download "update-kicad-repos.ps1" and move to your KiCad folder e.g. C:\Program Files\KiCad
3. Download "update-kicad-repos.xml" and import as a new task in Task Scheduler.
4. Select for the task to run whether user is logged on or not.
5. Setup a trigger (otherwise it won't automatically run).
6. Click OK and enter the password for the current user.
7. Find "Update KiCad Repos" in the list, right click and click Run.
@richard-scott
richard-scott / gist:f2b9ddb0e888878aca4e01eab46a7e98
Created December 5, 2018 09:25 — forked from corsonr/gist:ba033db9978a536b2b05
Store and display WooCommerce order total weight
<?php
// Store cart weight in the database
add_action('woocommerce_checkout_update_order_meta', 'woo_add_cart_weight');
function woo_add_cart_weight( $order_id ) {
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
update_post_meta( $order_id, '_cart_weight', $weight );
}
@richard-scott
richard-scott / socksimap.py
Created March 15, 2019 14:39 — forked from sstevan/socksimap.py
Python (v2 - v3) - IMAP through SOCKS proxy using PySocks module
import ssl
from socks import create_connection
from socks import PROXY_TYPE_SOCKS4
from socks import PROXY_TYPE_SOCKS5
from socks import PROXY_TYPE_HTTP
from imaplib import IMAP4
from imaplib import IMAP4_PORT
from imaplib import IMAP4_SSL_PORT
@richard-scott
richard-scott / gist:5681f13ec5137ef16d231d12529cebec
Created March 15, 2019 16:40
HTTP proxy support for Python's xmlrpclib
"""
Provide HTTP proxy support for Python's xmlrpclib, via urllib2.
For example:
>>> transport = HTTPProxyTransport({
... 'http': 'http://myproxyserver',
... })
>>> server = xmlrpclib.Server('http://blogsearch.google.com/ping/RPC2',
... transport=transport)