Skip to content

Instantly share code, notes, and snippets.

@uchidama
uchidama / alpha_png_rot_python_opencv.ipynb
Created March 6, 2018 09:54
Rotate png image while holding the alpha channel in opencv-python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@janselv
janselv / UIBezierPathLength.swift
Last active March 8, 2023 08:20
Get total iOS CGPath length as an extension of UIBezierPath written in swift
// The MIT License (MIT)
//
// Copyright (c) 2016 Jansel Valentin
//
// 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 permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@JonathonReinhart
JonathonReinhart / SConstruct
Last active January 6, 2024 06:42
mkdir -p implemented in C
env = Environment(
CCFLAGS = ['-Wall', '-Werror'],
)
env.Program('mkdir_p_test', ['mkdir_p.c', 'test.c'])
@blundgren
blundgren / gist:a68d70f792f138bae23b
Created March 11, 2016 17:56
An NSClipView subclass which performs drag-scrolling.
class DraggableClipView: NSClipView
{
private var clickPoint: NSPoint!
private var originalOrigin: NSPoint!
override func mouseDown(event: NSEvent) {
clickPoint = event.locationInWindow
originalOrigin = bounds.origin
}
@boyvanamstel
boyvanamstel / archive-post-action.sh
Last active July 17, 2023 04:53
Xcode archive post-action to copy zip, dSYM and DMG (using DropDMG) to desktop
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${SOURCE_ROOT}/${INFOPLIST_FILE}")
BUILD=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${SOURCE_ROOT}/${INFOPLIST_FILE}")
# The build number gets automatically increased by a build phase
BUILD=$((BUILD - 1))
DATE=$(/bin/date +%Y%m%d%H%M%S)
OUTPUT_DIR="${HOME}/Desktop/${TARGET_NAME}_v${VERSION}b${BUILD}_${DATE}"
mkdir "$OUTPUT_DIR"
# Zip and copy .dSYM
cd "${ARCHIVE_DSYMS_PATH}/"
/usr/bin/zip -r "$OUTPUT_DIR/${TARGET_NAME}.dSYM.zip" "${TARGET_NAME}.app.dSYM"
@swillits
swillits / NSDICT.m
Last active May 2, 2023 13:48
Obj-C NSDictionary Literal-like syntax allowing nil values
/*
---------------------------------------------------------------------------------------
Obj-C Literal Dictionary Syntax - Multiple reasons for allowing nil values
Radar 19747372
---------------------------------------------------------------------------------------
The obj-c literal syntax for dictionaries does not allow nils.
@{key : nil}; // Exception (and compiler error)
@keicoder
keicoder / UITextView subclass for supporting string, regex search and highlighting.m
Created March 14, 2014 10:42
objective-c : UITextView subclass for supporting string, regex search and highlighting
//UITextView subclass for supporting string, regex search and highlighting
//Created by Ivano Bilenchi on 05/11/13
//ICAppDelegate.h
@interface ICAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR
@joelrfcosta
joelrfcosta / printFreeMemory.m
Created June 5, 2013 16:16
iOS avalilable memory
- (void)printFreeMemory
{
return;
mach_port_t host_port;
mach_msg_type_number_t host_size;
vm_size_t pagesize;
host_port = mach_host_self();
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);