Skip to content

Instantly share code, notes, and snippets.

View adib's full-sized avatar

Sasmito Adibowo adib

View GitHub Profile
eddieespinal / cropCameraImage.swift
Last active April 14, 2021 08:16
Crops a Picture from AVCaptureSession to the bounds of the AVCaptureVideoPreviewLayer (so Preview = CameraImage) - Swift Version
//This is the swift version of the following gist by @shexbeer
func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? {
var image = UIImage()
let previewImageLayerBounds = previewLayer.bounds
let originalWidth = original.size.width
let originalHeight = original.size.height
breiter / Markdown.mdimporter.patch
Last active October 30, 2023 10:24
Enable Spotlight indexing of Markdown in ~~El Capitan~~ Monterey without disabling SIP
--- /System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist 2022-02-26 09:05:07.000000000 +0200
+++ /Library/Spotlight/Markdown.mdimporter/Contents/Info.plist 2022-03-22 21:01:30.000000000 +0200
@@ -13,27 +13,20 @@
- <string>public.rtf</string>
- <string>public.html</string>
- <string>public.xml</string>
- <string>public.plain-text</string>
# Get Homebrew in the new location
git clone ~/Homebrew
# Move all your installed packages to the new location
mv /usr/local/Cellar ~/Homebrew/Cellar
mv /usr/local/Library ~/Homebrew/Library
# Remove "root" directory files left behind
rm -rf /usr/local/.git /usr/local/{.gitignore,.yardopts,,,LICENSE.txt,,}
hephaestus9 /
Last active June 13, 2017 14:50
Sieve Of Atkin - Java
* The function of this class is to find all prime numbers in range given by the user.
* This homework assignment requires several references:
ericallam / RotateKeynoteDocumentDroplet
Created July 31, 2014 11:12
Rotate Keynote Document for use as an app Prototype
// Open Script Editor and Export this as an Application
// Then drop a keynote file on it in the Finder and it will properly resize
// and rotate everything so the Keynote file becomes usable as a prototype
// in the iPhone keynote app
// rotateDocument exported function
// Accepts a Keynote document and will rotate
// all the slides and elements in the slide 90 degrees
akisute /
Last active July 3, 2017 05:16
How to build ncurses-5.9 for iOS :D
# Just comment out these lines in L4428 before ./configure
if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
{ { echo "$as_me:4429: error: Cross-build requires two compilers.
Use --with-build-cc to specify the native compiler." >&5
echo "$as_me: error: Cross-build requires two compilers.
Use --with-build-cc to specify the native compiler." >&2;}
{ (exit 1); exit 1; }; }
coreh / ScreenCapture.m
Last active April 20, 2023 16:37
Screen capture in Cocoa (Grabs the screen contents and puts it into a NSImage)
NSImage *CaptureScreen() {
// Get the Screen Rect
NSRect screenRect = [[NSScreen mainScreen] frame];
// Create a CGImage with the screen contents
CGImageRef cgImage = CGWindowListCreateImage(screenRect, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
// Convert the CGImage into a NSBitmapImageRep
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
KartikTalwar /
Last active June 25, 2024 10:55
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
evandrix /
Created September 11, 2012 00:06
Headless web browsers

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.