Skip to content

Instantly share code, notes, and snippets.

/*
* An example of
* 1. Using the YUI 3 module system to encapsulate a custom class for reuse
* 2. Creating a Plugin class
* 3. Using Y.Base.create to generate the class
*/
// YUI.add(
// "dash-separated-module-name",
// function (Y) { Y.MyModule = ...; },
@lsmith
lsmith / datatable-events.js
Created December 26, 2010 19:30
A DataTable plugin to create a set of notification events for convenience beyond myDataTable.delegate('click', callback, 'tr') for row clicks etc
YUI.add('datatable-events', function (Y) {
var isString = Y.Lang.isString;
Y.Plugin.DataTableEvents = Y.Base.create('dataTableEvents', Y.Plugin.Base, [], {
initializer: function () { // Or possibly this.afterHostMethod('bindUI', this._initEvents);
this.get('host').after('render', this._initEvents, this);
},
@lsmith
lsmith / datatable-events.js
Created July 8, 2011 00:12
A Plugin to create cellClick, rowMousedown, etc events on DataTable
YUI.add('datatable-events', function (Y) {
Y.Plugin.DataTableEvents = Y.Base.create('dtevents', Y.Plugin.Base, [], {
initializer: function (config) {
this.afterHostMethod('bindUI', function () {
this._bindEvents(this.get('events'));
this.after('eventsChange', this._afterEventsChange);
});
},
@lsmith
lsmith / gist:1091534
Created July 19, 2011 07:07
A POC inline cell editor class extension/view for YUI 3 DataTable
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test Page</title>
<style>
.yui3-skin-sam .yui3-datatable .yui3-datatable-data .yui3-datatable-editing {
position: relative;
padding: 0;
}
@nanoant
nanoant / sidebar.m
Created September 27, 2011 10:52
Change your Lion sidebar item icons
// (l) copyleft 2011 Adam Strzelecki nanoant.com
//
// Usage:
// sidebar - to see the ids of your favorite sidebar items
// sidebar ItemName - to remove item specific icon
// sidebar ItemName sbBj - to set specific item icon, see:
// /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist
// Compile it with:
// gcc -o sidebar sidebar.m -F /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks -framework Foundation -framework CoreServices
//
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@pudquick
pudquick / keymaster.py
Last active May 26, 2020 15:13
Pythonic in-depth control of the user keychain domain
import os.path, base64
from ctypes import CDLL, Structure, POINTER, byref, addressof, create_string_buffer, c_int, c_uint, c_ubyte, c_void_p, c_size_t
from CoreFoundation import kCFStringEncodingUTF8
# Wheee!
Security = CDLL('/System/Library/Frameworks/Security.Framework/Versions/Current/Security')
# I don't use the pyObjC CoreFoundation import because it attempts to bridge between CF, NS, and python.
# When you try to mix it with Security.Foundation (pure C / CF), you get nasty results.
# So I directly import CoreFoundation to work with CFTypes to keep it pure of NS/python bridges.
CFoundation = CDLL('/System/Library/Frameworks/CoreFoundation.Framework/Versions/Current/CoreFoundation')
@timsutton
timsutton / auto-update-mas-apps.sh
Last active March 7, 2018 06:54
Clear storeagent cache and trigger Mac App Store app updates.
#!/bin/sh
#
# Trigger an update of MAS (and softwareupdate) apps
#
# This seems to be all that's needed to schedule an immediate update of
# MAS apps. This should be run as a normal user. You can run this and
# tail the install log to get an idea of what's happening.
#
# You can also take a look at this user's ~/Library/Caches/com.apple.storagent
# directory to get a report on what apps were available, installable, etc.
@pudquick
pudquick / http_flatpkg_pkginfo.py
Created May 11, 2014 07:13
This python project is able to retrieve the PackageInfo metadata from flatpkg files over HTTP without downloading the entire .pkg file (if the web server it's hosted on supports partial file transfer / byte ranges)
# Skip to the end to see what this can do.
#
# http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html
# Flat packages are xar files with a particular structure
# We're looking for the PackageInfo file within the xar file
import urllib2, ctypes, zlib
import xml.etree.ElementTree as ET
class SimpleObj(object):
@pudquick
pudquick / parse_pbzx.py
Last active September 27, 2021 04:34
Pure python reimplementation of .cpio.xz content extraction from pbzx file payload for OS X packages
# Pure python reimplementation of .cpio.xz content extraction from pbzx file payload originally here:
# http://www.tonymacx86.com/general-help/135458-pbzx-stream-parser.html
#
# Cleaned up C version (as the basis for my code) here, thanks to Pepijn Bruienne / @bruienne
# https://gist.github.com/bruienne/029494bbcfb358098b41
# Example usage:
# parse_pbzx('PayloadJava', 'PayloadJava.cpio.xz')
# Updated for speeeeeeeeeeeeed