Skip to content

Instantly share code, notes, and snippets.

View lashomb's full-sized avatar

lashomb lashomb

View GitHub Profile
@macshome
macshome / IOKit.swift
Last active February 18, 2026 06:26
This playground shows you a few different ways to get device info via IOKit.
// This playground shows you a few different ways to get device info via IOKit.
// If you want to explore IOKit and look for interesting data I would download
// the Additional Developer Tools from Apple and use the IORegistryExplorer app.
// It makes it super easy to poke around in the IOKit planes.
import IOKit
import Foundation
// For convient access we can make a computed getter for the PlatformExpert.
// Traditionally this has been where you go to find all sorts of data about the
@woble
woble / dell-h310.md
Created November 5, 2017 10:54
Flashing Dell PERC H310 to IT mode

If you have a Dell Perc H310 and your computer won't boot then you'll need to cover PCIe pins B5 and B6. You can cover them with a thin piece of electrical tape.

H310 DOS

  1. megacli.exe -AdpAllInfo -aAll -page 20 Write down SAS address.
  2. megarec.exe -writesbr 0 sbrempty.bin If this fails move on to next step.
  3. megarec.exe -cleanflash 0 Reboot.
  4. sas2flsh.exe -o -f 6GBPSAS.fw Reboot.
  5. sas2flsh.exe -o -f 2118it.bin
  6. s2fp19.exe -o -sasadd 500xxxxxxxxxxxxx
@gregneagle
gregneagle / fancy_defaults_read.py
Last active August 24, 2025 09:36
fancy_defaults_read.py: Reads a preference, prints its value, type, and where it is defined.
#!/usr/bin/python
import os
import sys
from CoreFoundation import (CFPreferencesAppValueIsForced,
CFPreferencesCopyAppValue,
CFPreferencesCopyValue,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost,
@apolloclark
apolloclark / Twitter API with Curl
Last active December 15, 2024 00:46
Twitter API with Curl
# create an account, create an app
# @see https://apps.twitter.com/
# retrieve the access tokens
# @see https://dev.twitter.com/oauth/reference/post/oauth2/token
# create the file ~/twitter_api
nano ~/twitter_api
Authorization: OAuth oauth_consumer_key="XXXXXX", oauth_nonce="11111111", oauth_signature="XXXXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1450728725", oauth_token="99999-XXXXXX", oauth_version="1.0"
@pudquick
pudquick / public_ip.txt
Created November 26, 2015 07:04
Resolve public IP address via DNS dig
dig +short myip.opendns.com @resolver1.opendns.com
@chilcote
chilcote / gist:6649e2867e1a547f4a06
Created October 11, 2015 18:58
Get primary interface name and IP
#!/usr/bin/python
from SystemConfiguration import SCDynamicStoreCreate, SCDynamicStoreCopyValue
net_config = SCDynamicStoreCreate(None, "net", None, None)
def get_primaryinterface():
states = SCDynamicStoreCopyValue(net_config, "State:/Network/Global/IPv4")
return states['PrimaryInterface']
@ricleal
ricleal / test_proxy.py
Last active July 1, 2018 20:12
UGLY HTTP connection with Auto Proxy & proxy.pac detection on Linux, OSx or Windows
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import json
from pprint import pprint
import sys
import re
@gregneagle
gregneagle / gist:01c99322cf985e771827
Created January 20, 2015 18:16
Using CFPreferences in Python to set a complex preference
import plistlib
import CoreFoundation
from Foundation import NSDate, NSMutableArray, NSMutableDictionary
# read the current ManagedPlugInPolicies
policy = CoreFoundation.CFPreferencesCopyAppValue("ManagedPlugInPolicies", "com.apple.Safari")
if policy:
# policy is an immutable dict, so we have to make a mutable copy
my_policy = NSMutableDictionary.alloc().initWithDictionary_copyItems_(policy, True)
@eahrold
eahrold / closeapp.py
Created January 14, 2014 18:00
close a running application with python and NSWorkspace
#!/usr/bin/python
from AppKit import NSWorkspace
def closeRunningApplication(bundle_id):
ws = NSWorkspace.sharedWorkspace()
runningApps = ws.runningApplications()
for i in runningApps:
if i.bundleIdentifier() == bundle_id:
i.terminate()
@ndfred
ndfred / push.py
Created October 30, 2012 21:41
A simple standalone script to test an Apple Push Notification setup
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A simple standalone script to test an Apple Push Notification setup.
Uses the feedback packets to provide the best information on how to fix things.
Steps to send a push notification: