Skip to content

Instantly share code, notes, and snippets.

@kylefox
kylefox / color.m
Created January 27, 2012 17:45
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
@fionawhim
fionawhim / unlock.scpt
Created May 31, 2012 20:31
Unlock screensaver via AppleScript in Lion
tell application "System Events"
if name of every process contains "ScreenSaverEngine" then
tell application "ScreenSaverEngine"
quit
end tell
keystroke <YOUR PASSWORD HERE>
keystroke return
end if
end tell
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@ku
ku / metatag.m
Created November 12, 2013 02:19
OSX10.9 tag manipulation util
#import <Foundation/Foundation.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// clang tag.m -o metatag -framework "foundation" -fobjc-arc && ./metatag
int main(int argc, char **argv) {
char *tagToAdd = NULL;
@c9iim
c9iim / AXUIElement_in_Swift.swift
Last active May 9, 2023 07:45
AXUIElement in Swift
import Cocoa
protocol AXUIProtocol {
func AXUIWindowArray(processIdentifier pid:pid_t) -> [AXUIElement]
func AXUIWindowArray(bundleIdentifier bid:NSString) -> [AXUIElement]
}
extension AXUIProtocol {
func AXUIWindowArray(processIdentifier pid:pid_t) -> [AXUIElement] {
let windowList : UnsafeMutablePointer<AnyObject?> = UnsafeMutablePointer<AnyObject?>.alloc(1)
@randomsequence
randomsequence / cocoa-drawing.swift
Created July 14, 2015 15:25
Drawing images with CGContext and NSGraphicsContext in Swift
//: Playground - noun: a place where people can play
import Cocoa
let bounds = CGRectMake(0, 0, 100, 100);
func DrawImageInCGContext(#size: CGSize, #drawFunc: (context: CGContextRef) -> ()) -> NSImage {
let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue)
let context = CGBitmapContextCreate(
@599316527
599316527 / ddns-start
Last active October 18, 2019 08:32
asuswrt-merlin custom ddns script for dnspod
#!/bin/sh
# This file should be placed in /jffs/scripts/ folder.
# 后台申请token
# https://support.dnspod.cn/Kb/showarticle/tsid/227/
login_token='xxxxxxx,yyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
# 先调 Domain.List 和 Record.List 接口取得 id
# https://www.dnspod.cn/docs/domains.html#domain-list
# https://www.dnspod.cn/docs/records.html#record-list
@ffeldhaus
ffeldhaus / ds215j_bootstrap_ng.md
Last active September 26, 2023 11:09
Bootstrap Synology ds215j using optware-ng

Bootstrap the Synology DS215j with optware-ng

I tried the instructions described in the Blogpost Bootstrap DS215j to install optware for ds215j but was unsatisfied with the long outdated packages it provided. Luckily, there now is optware-ng which is a fork of optware and provides recent packages.

This is how I managed to install optware-ng on my Synology ds215j inspired by the instructions in the Gist Boostrap the Synology DS215j with optware, ipkg, and sudo:

Download & Install ipkg in a persistent manner

# become root

sudo -i

I am not a fan of Xcode. Here are ~160~ 200 problems, the first hundred or so issues were filed mostly in
July and August 2016 in a fit of rage. Mostly on weekends working (slowly) on side-projects. I have also
taken days of my employer's time filing others of these - so the company was not getting value for my time.
I believe a paid intern could have found many of these - just start a screen recorder, and when you see something,
stop and cut a quick movie. Many have been around for several major versions.
I'm volunteering chunks of my life (15-30 minutes per) to one of the most valuable companies in the world, which seems
kind of messed up. Things get worse the more complex the project and the longer Xcode been's running.
Apple folks - check out rdar://22524679
@eguven
eguven / brew-list.sh
Last active February 7, 2024 06:16
List all packages installed using Homebrew and their sizes
brew list --formula | xargs -n1 -P8 -I {} \
sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \
sort -h -r -k2 - | column -t