Skip to content

Instantly share code, notes, and snippets.

View AhiyaHiya's full-sized avatar

Jaime AhiyaHiya

View GitHub Profile
@AhiyaHiya
AhiyaHiya / byte_order.c
Created December 7, 2017 15:35
Detecting byte order for cases where you need to know. Originally in Obj-C, adapted from iOS macOS Network Cookbook available on Safaribooks.com
typedef enum {
ET_Unknown,
ET_Little,
ET_Big
} endian_type_e;
endian_type_e byte_order()
{
union {
short num_as_short;
set -e
set -u
# https://stackoverflow.com/questions/1028649/how-do-you-rename-a-git-tag
# old_name new_name
rename_git_tag()
{
local readonly old=$1
local readonly new=$2
@AhiyaHiya
AhiyaHiya / keybindings.json
Last active February 19, 2018 15:15
Keyboard shortcut mapping for Visual Studio Code to have same shortcuts as Xcode
[
{
"key": "ctrl+cmd+left",
"command": "workbench.action.navigateBack"
},
{
"key": "ctrl+cmd+right",
"command": "workbench.action.navigateForward"
},
{
@AhiyaHiya
AhiyaHiya / VersionString.swift
Created November 1, 2017 15:37
Set the version label from the plist info (iOS and macOS)
func setVersionLabel()
{
let mainBundle = Bundle.main
let version = mainBundle.infoDictionary!["CFBundleShortVersionString"] as! String
let build = mainBundle.infoDictionary![kCFBundleVersionKey as String] as! String
versionLabel.text = "Version \(version) Build: \(build)"
}
@AhiyaHiya
AhiyaHiya / keybindings.json
Created August 24, 2017 20:53
Key shortcuts to make Visual Studio Code behave more like Xcode
[
{ "key": "alt+cmd+left", "command": "editor.fold",
"when": "editorTextFocus" },
{ "key": "alt+cmd+right", "command": "editor.unfold",
"when": "editorTextFocus" },
{ "key": "cmd+alt+[", "command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus" },
{ "key": "cmd+alt+]", "command": "editor.action.moveLinesDownAction",
"when": "editorTextFocus" },
@AhiyaHiya
AhiyaHiya / AnimateUILabel.m
Created August 22, 2017 15:04
Animate UILabel... pretty simply said.
// https://stackoverflow.com/questions/3073520/animate-text-change-in-uilabel
//
- (void)animate:(UILabel*)label with:(NSString*)text
{
CATransition* animation = [CATransition animation];
animation.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.type = kCATransitionFade;
animation.duration = 0.75;
[label.layer addAnimation:animation forKey:@"kCATransitionFade"];
@AhiyaHiya
AhiyaHiya / run_opencv_tests.sh
Created August 21, 2017 20:26
Runs OpenCV tests, which are required prior to creating pull request.
#!/bin/bash
# shell script to execute OpenCV tests prior to creating pull request
set -o errexit
set -o nounset
main()
{
cd $CURRENT_PATH/build/bin/Debug
./opencv_annotation
./opencv_createsamples
@AhiyaHiya
AhiyaHiya / VersionString.m
Last active August 5, 2017 23:54
A function I use to update version string on the layout.
@implementation VersionStringDemo
- (void)updateVersionLabel
{
NSString* version =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString* build =
[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
NSString* versionString = [NSString stringWithFormat:@"Version: %@ Build: %@", version, build];
@AhiyaHiya
AhiyaHiya / setup_opencv_macos.sh
Last active October 28, 2024 03:52
Download and build OpenCV framework for macOS
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
setup_opencv()
{
printf "*********************************\n${FUNCNAME[0]}\n"
local readonly PARENT_FOLDER=${1:-third_party}
@AhiyaHiya
AhiyaHiya / getDomainFromEmailSender
Last active July 31, 2017 20:01
AppleScript that gets URL from sender email address
tell application "Mail"
set mySelection to selection
set myMessage to item 1 of mySelection
set theSender to sender of myMessage
extract address from theSender
-- https://stackoverflow.com/questions/15670363/applescript-to-find-domain-of-the-sender-of-mail-and-add-it-to-the-rules
set theDomain to (do shell script "echo " & quoted form of rich text 1 through -2 of theSender & " | awk " & quoted form of "{split($0,a,\"@\"); print a[2]}")
display dialog theDomain