Skip to content

Instantly share code, notes, and snippets.

View palmin's full-sized avatar

Anders Borum palmin

View GitHub Profile
var _require_cache_ = {};
function require(name) {
let local = FileManager.local();
// look for script with the given name in iCloud documents
// and current directory adding .js to filename is not present
let resolve = function(name) {
var filename = name;
if(name.indexOf('.js') < 0) {
filename += '.js';
extension URLRequest {
private func quote(_ string: String) -> String {
// handle all the regular escape sequences
var text = string.replacingOccurrences(of: "\\", with: "\\\\")
text = text.replacingOccurrences(of: "\"", with: "\\\"")
text = text.replacingOccurrences(of: "\n", with: "\\\n")
text = text.replacingOccurrences(of: "\r", with: "\\\r")
text = text.replacingOccurrences(of: "\t", with: "\\\t")
return "\"\(text)\""
}
// we check if we are running as beta-app by looking at path for receipt
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSString *receiptURLString = [receiptURL path];
BOOL testFlight = ([receiptURLString rangeOfString:@"sandboxReceipt"].location != NSNotFound);
@palmin
palmin / Merge Pull Request.py
Last active March 30, 2023 15:39
Merge Pull Request.py
#!python2
# coding: utf-8
#
# This script is meant to be used from the Pythonista action extension when Safari is showing
# a GitHub Pull Request and will ask Working Copy to merge+pull the pull-request thus fullfulling it.
# You need to already have this repository cloned in Working Copy.
#
# It only works on public repositories, since the script lacks a way to authorize, but things
# happening in Working Copy can be fully authorized with either SSH Key or username / password.
#

Keybase proof

I hereby claim:

  • I am palmin on github.
  • I am palmin (https://keybase.io/palmin) on keybase.
  • I have a public key whose fingerprint is D6E5 1709 0C54 8B06 6311 4E19 8E87 F332 DFBA A768

To claim this, I am signing this object:

@palmin
palmin / gist:14300e8bf529d05e7e53
Last active September 25, 2022 07:55 — forked from shannoga/gist:1008678
Get fonts family and font names list on iOS
// List all fonts on iPhone
for (NSString* family in [UIFont familyNames]) {
NSLog(@"Family name: %@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family]) {
NSLog(@" Font name: %@", name);
}
}
@interface UIView (InspectableBorder)
@property (nonatomic, assign) IBInspectable CGFloat borderWidth;
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;
@end
@implementation UIView (InspectableBorder)
-(CGFloat)borderWidth {
@palmin
palmin / test.yaml
Last active August 29, 2015 14:13
comprehensive but short yaml-file for testing with highlight.js
---
receipt: Oz-Ware Purchase Invoice
date: 2012-08-06
customer:
given: Dorothy
family: Gales
items:
- part_no: A4786
descrip: Water Bucket (Filled)