Skip to content

Instantly share code, notes, and snippets.

View jxpx777's full-sized avatar
🤠

Jamie Phelps jxpx777

🤠
View GitHub Profile
@jxpx777
jxpx777 / FileTagger.m
Created February 25, 2014 15:36
A demonstration of how to read and set tags using xattr APIs.
- (NSSet *)tagsForFileAtPath:(NSString *)path {
const char *attrName = [@"com.apple.metadata:_kMDItemUserTags" UTF8String];
const char *filePath = [path fileSystemRepresentation];
ssize_t bufferLength = getxattr(filePath, attrName, NULL, 0, 0, 0);
void *buffer = malloc(bufferLength);
// now actually get the attribute string
getxattr(filePath, attrName, buffer, 255, 0, 0);
// convert to NSString
@jxpx777
jxpx777 / internet_fail.md
Last active August 29, 2015 13:56
Charter internet slowness
--- google.com ping statistics ---
228 packets transmitted, 228 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 39.070/1937.931/19344.446/3880.397 ms



@jxpx777
jxpx777 / SassMeister-input-HTML.html
Created April 6, 2014 17:04
Generated by SassMeister.com.
<!DOCTYPE html>
<html>
<head>
<title>FWUPA</title>
<meta content="authenticity_token" name="csrf-param" />
<meta content="NIhzA2wh/3UWZa5iS7ts9qmX69QwoaXxXG6UseNuLpE=" name="csrf-token" />
</head>
<body>
<section id="wrap">
class String
def to_numeronym
self.gsub(/\A(.)(.*)(.)\Z/) { "#{$1}#{$2.length}#{$3}" }
end
end
var WebSocket = null;
hiddenFrames.add(hiddenFrames.HiddenFrame({
'onReady': function () {
var self = this; // Don't use bind for `this` since GCC warns w/ "dangerous use of the global this object"
self.element.contentWindow.location = require("sdk/self").data.url("ui/hidden.html");
self.element.addEventListener("DOMContentLoaded", function () {
console.log("Initializing WebSocket for '" + self.element.contentWindow.location + "'");
//noinspection JSUnresolvedVariable
WebSocket = self.element.contentWindow.MozWebSocket || self.element.contentWindow.WebSocket;
@jxpx777
jxpx777 / open_in_active_tab.js
Created February 19, 2015 19:31
The goal is to open a URL in the active tab. If one does not exist, we should open a new tab for it.
function openURLInActiveTab(url){
if (tabs.activeTab.url === undefined) {
tabs.open({url: url, onOpen: function onOpen(tab) { console.log("[GLOBAL]: Opened tab: " + tab); tab.activate(); tab.url = url; }});
}
else {
tabs.activeTab.url = url;
}
}
@jxpx777
jxpx777 / Reload Extension Builder.kmmacros
Created August 4, 2015 17:42
Reload Safari's Extension Builder using ⌘R in Keyboard Maestro. Additionally, if the Inspect Global Page window was open, it will be reopened. (This assumes your global page is named global.html. Adjust the menu item conditional if not.)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>CreationDate</key>
<real>460387677.55399102</real>
<key>IsActive</key>
//
// NSMetadataItem+JPIKImageBrowserItem.m
// Created by Jamie Phelps on 10/20/09.
//
// Licensed under the Don't Be A Dick License
//
@interface NSMetadataItem (JPIKImageBrowserItem)
-(NSString *)imageUID;
-(NSString *)imageRepresentationType;
//
// NSMetadataItem+JPQLPreviewItem.m
// Created by Jamie Phelps on 2/6/10.
//
// Licensed under the Don't Be A Dick License
//
@interface NSMetadataItem (JPQLPreviewItem)
-(NSString *)previewItemTitle;
-(NSURL *)previewItemURL;
<script type="text/javascript">
// <![CDATA[
eCSStender.disableCache();
eCSStender.addMethod('findBySelector',Sizzle);
function testSupport( selector )
{
try {
eCSStender.methods.findBySelector(selector);
}
catch( e )