Skip to content

Instantly share code, notes, and snippets.

on enabledGUIScripting(flag)
get system attribute "sysv"
if result is less than 4240 then -- 4240 is OS X 10.9.0 Mavericks
-- In OS X 10.8 Mountain Lion and older, enable GUI Scripting globally by calling this handler and passing 'true' in the flag parameter before your script executes any GUI Scripting commands, or pass 'false' to disable GUI Scripting. Authentication is required only if the value of the 'UI elements enabled' property will be changed. Returns the final setting of 'UI elements enabled' even if unchanged.
tell application "System Events"
activate -- brings System Events authentication dialog to front
set UI elements enabled to flag
return UI elements enabled
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@acdha
acdha / custom-log-filtering-and-formatting.py
Created February 26, 2014 21:19
Example of how to filter or apply custom formatting using Python's logging library
#!/usr/bin/env python
# encoding: utf-8
from pprint import pformat, pprint
import logging
class PasswordMaskingFilter(logging.Filter):
"""Demonstrate how to filter sensitive data:"""
@Ventero
Ventero / userval.user.js
Created January 21, 2014 17:29
Greasemonkey user variable definition example
function makeUserModifiable(varName, defaultVal, parseFunc) {
if(typeof parseFunc !== "function")
parseFunc = function(a) { return a; };
var currentVal = GM_getValue(varName, defaultVal);
GM_registerMenuCommand("Set variable " + varName, function() {
var val = prompt("Value for " + varName, currentVal);
GM_setValue(varName, val);
// if you need live modification, uncomment this (requires varName to be a
// global variable)
@mcolyer
mcolyer / chapters-to-sbv.rb
Created January 16, 2014 00:40
A very simple tool to convert from [subler](https://code.google.com/p/subler/) chapter export to SBV subtitle format so that youtube will accept it.
#!/usr/bin/env ruby
contents = File.read(ARGV[0])
values = {}
chapters = []
contents.each_line do |line|
key, value = line.split('=')
values[key] = value.strip
next if key =~ /NAME/
@jameshfisher
jameshfisher / How to make a private Gist public.md
Created January 5, 2014 16:31
How to make a private Gist public

Github provides no facility to do this via the UI. This is sad, because it would be extremely useful in order to draft something before publishing it. It would also be trivial for them to implement. Never mind; here's how to do it manually:

  1. Get the "Clone this Gist" text from the left-hand side of the private Gist, e.g. https://gist.github.com/b9cc265982870c091a1e.git, and extract the ID b9cc265982870c091a1e.
  2. Go to https://gist.github.com/ and create a dummy new public Gist.
  3. Get the "Clone this Gist" text from the left-hand side, e.g. https://gist.github.com/8270253.git, and extract the ID 8270253.
  4. git clone [email protected]:b9cc265982870c091a1e tmp-dir && cd tmp-dir && git push -f [email protected]:8270253.git
@ourway
ourway / File-Search-Multi-process
Created December 31, 2013 13:40
Example of multi-process huge files searching
import multiprocessing, os, time
NUMBER_OF_PROCESSES = multiprocessing.cpu_count()
def FindText( host, file_name, text):
file_size = os.stat(file_name ).st_size
m1 = open(file_name, "r")
#work out file size to divide up to farm out line counting
chunk = (file_size / NUMBER_OF_PROCESSES ) + 1
@jvns
jvns / interview-questions.md
Last active April 17, 2025 16:25
A list of questions you could ask while interviewing

A lot of these are outright stolen from Edward O'Campo-Gooding's list of questions. I really like his list.

I'm having some trouble paring this down to a manageable list of questions -- I realistically want to know all of these things before starting to work at a company, but it's a lot to ask all at once. My current game plan is to pick 6 before an interview and ask those.

I'd love comments and suggestions about any of these.

I've found questions like "do you have smart people? Can I learn a lot at your company?" to be basically totally useless -- everybody will say "yeah, definitely!" and it's hard to learn anything from them. So I'm trying to make all of these questions pretty concrete -- if a team doesn't have an issue tracker, they don't have an issue tracker.

I'm also mostly not asking about principles, but the way things are -- not "do you think code review is important?", but "Does all code get reviewed?".

@mikeal
mikeal / gist:7724521
Last active December 29, 2015 20:29
Inclusive by Exclusion

When you build a community you're creating a culture. That culture will be about more than the code, the modules, or the language. The people you draw in will have their own biases and behaviors that impact the kinds of people you continue to draw as you grow.

Cultures will naturally fight behavior that is divisive. That is, behavior that is divisive to the established members of that community. As a community grows larger it is harder and harder to change what the culture finds acceptable because changing it, even if it is inclusive in nature, is disturbing and divisive to existing membership. Fighting for change in established cultures means dealing with a lot of dismissive language and attacks for the "tone" of your argument.

That is why it is so important that a culture becomes comfortable with aggressively fighting exclusionary behavior. While it is certainly more beneficial to make pro-active steps to increase diversity we cannot be dismissive of the effect that passionate reactions to poor behavior

#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten