Skip to content

Instantly share code, notes, and snippets.

View natewalck's full-sized avatar

Nate Walck natewalck

View GitHub Profile
#!/usr/bin/python
'''Uses Cocoa classes via PyObjC to set a random desktop picture on all screens.
Tested on Mountain Lion and Mavericks.
See:
https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWorkspace_Class/Reference/Reference.html
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
@natewalck
natewalck / pids.py
Created February 18, 2014 19:37 — forked from pudquick/pids.py
from ctypes import CDLL, sizeof, memset, c_uint32, create_string_buffer
MAXPATHLEN = 1024
PROC_PIDPATHINFO_MAXSIZE = MAXPATHLEN*4
PROC_ALL_PIDS = 1
libc = CDLL('libc.dylib')
def get_pids():
number_of_pids = libc.proc_listpids(PROC_ALL_PIDS, 0, None, 0)
pid_list = (c_uint32 * (number_of_pids * 2))()
#!/bin/bash
# Dashing service
# Add this file to /etc/init.d/
# $ sudo cp dashboard /etc/init.d/
# Update variables DASHING_DIR, GEM_HOME, & PATH to suit your installation
# $ sudo nano /etc/init.d/dashboard
# Make executable
# $ sudo chmod 755 /etc/init.d/dashboard
# Update rc.d
# $ sudo update-rc.d dashboard defaults
host = Host.new(:name => "whatever", :environment => Environment.first)
host.save
osfamily_fact = FactValue.new(:value => "windows", :fact_name => FactName.find_by_name('osfamily'), :host => host)
osfamily_fact.save
@natewalck
natewalck / cocoa_keypress_monitor.py
Last active August 29, 2015 14:27 — forked from ljos/cocoa_keypress_monitor.py
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
# cocoa_keypress_monitor.py by Bjarte Johansen is licensed under a
# License: http://ljos.mit-license.org/
from AppKit import NSApplication, NSApp
from Foundation import NSObject, NSLog
from Cocoa import NSEvent, NSKeyDownMask
from PyObjCTools import AppHelper
class AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, notification):
H
g/-Wl,-search_paths_first/d
g/ -lSystemStubs -arch_only [^"]*/s///
g/-current_version $(VERSION)/s//-current_version $(PYTHON_CURRENT_VERSION)/
g/-O3/s//-Os/g
/^OTHER_LIBTOOL_OPT$/i
EXTRA_CFLAGS
LIBTOOL
.
/# Calculate the right deployment target for this build\./i
H
/^#include/a
#include <stdlib.h>
.
/^get_history_item(/a
.
/^#ifdef *__APPLE__/c
/*
* Recent versions of libedit have corrected the off-by-one history indexes
* (though the Apple version emulates a true offset rather than using the
H
/^def macosx_sdk_root(/a
.
/cflags =/i
sdkroot = os.environ.get('SDKROOT')
if sdkroot is not None:
return sdkroot
.
/# Check the additional directories$/a
.
# main config
libdir = /usr/share/mcollective/plugins
logfile = /var/log/mcollective.log
daemonize = 1
keeplogs = 1
max_log_size = 10240
loglevel = debug
identity = my_laptop
registerinterval = 300
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static