Skip to content

Instantly share code, notes, and snippets.

View kewlbear's full-sized avatar

Changbeom Ahn kewlbear

View GitHub Profile
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@ccwasden
ccwasden / WithPopover.swift
Created February 5, 2020 13:39
Custom size popover in iOS SwiftUI
// -- Usage
struct Content: View {
@State var open = false
@State var popoverSize = CGSize(width: 300, height: 300)
var body: some View {
WithPopover(
showPopover: $open,
popoverSize: popoverSize,
@niw
niw / README.en.md
Last active February 13, 2024 04:24
How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac. Enjoy!

NOTE: that this is current, 10/1/2021 state.

Running Windows 10 on ARM

  1. Install Xcode from App Store or install Command Line Tools on your Mac
@bkeating
bkeating / howto-filemerge-git-osx.md
Created March 11, 2010 21:36
HOWTO: Using FileMerge (opendiff) with Git on OSX

HOWTO: Using FileMerge (opendiff) with Git on OSX

FileMerge (opendiff) can really come in handy when you need to visually compare merging conflicts. Other times it's just a nice visual way to review your days work.

The following method works by creating a simple bash script (git-diff-cmd.sh) that sets us up with the proper command line arguments for Git to pass off files to FileMerge.

@NSURLSession0
NSURLSession0 / cloudkit-server.php
Created February 7, 2016 21:36
CloudKit server-to-server in PHP
<?php
// Constants
$KEY_ID = 'YOUR_KEY_ID';
$CONTAINER = 'YOUR_CONTAINER';
$PRIVATE_PEM_LOCATION = 'eckey.pem'; // Store this file outside the public folder!
// Config
$url = 'https://api.apple-cloudkit.com/database/1/' . $CONTAINER . '/development/public/records/query';
$body = '{"query":{"recordType":"Articles"}}';
@simonbs
simonbs / childForStatusBarStyle.swift
Last active September 25, 2023 14:49
It seems that -childForStatusBarStyle: isn’t called on a UIViewController that is presented from a SwiftUI view using UIViewControllerRepresentable. Or am I doing something wrong? I came up with this *ugly* workaround that swizzles -childForStatusBarStyle: to return an associated object when present and uses the default implementation as fallback.
// We'll store a UIViewController as an associated object and don't want to store a strong reference to it.
private final class WeakBoxedValue<T: AnyObject>: NSObject {
private(set) weak var value: T?
init(_ value: T?) {
self.value = value
}
}
// Use associated objects to a UIViewController that should determine the status bar appearance.
cmake_minimum_required(VERSION 2.8.4)
project(so29595222)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
ADD_DEFINITIONS( -std=c++11 )
set(SOURCE_FILES python_threading_example_so29595222.cpp)
@joshenders
joshenders / mitmproxy.md
Last active July 23, 2023 14:49
mitmproxy configuration for iPad

Successful mitmproxy-3.7 setup tested on OS X 10.13.6 and iPhone X running 12.1.4

Enable IP forwarding and disable ICMP redirects to keep the iPad sending traffic to the proxy

sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet.ip.redirect=0

net.inet.ip.forwarding
Enable IP forwarding between interfaces

@johngray1965
johngray1965 / build_pdfium.sh
Last active June 8, 2023 11:41
Script for build pdfium for Android
#! /bin/bash
# current the latest stable android branch (from Jan 2020)
githash=daabea6ba6c09f72e956e826b132f1d1b77acb9b
# if want to run this from somewhere other then /data adjust below
basedir=/data
# exit when any command fails
set -e