Skip to content

Instantly share code, notes, and snippets.

View kabouzeid's full-sized avatar

Karim Abou Zeid kabouzeid

View GitHub Profile
@kabouzeid
kabouzeid / codes.ka.ssh-add-keychain.plist
Last active April 21, 2023 08:37
Launch agent to add ssh keys to the agent on login.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>codes.ka.ssh-add-keychain</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ssh-add</string>
<string>--apple-load-keychain</string>
@kabouzeid
kabouzeid / patch.ff
Last active December 10, 2022 12:26
FontForge script to cleanly patch a font with a set of symbols fonts.
#!/usr/bin/env fontforge
# Usage: patch.ff <font_to_patch> <symbol_font_1> ... <symbol_font_n>
Open($1)
###
### PS NAMES
###
@kabouzeid
kabouzeid / set_default_editor.sh
Last active November 6, 2022 20:28
Set the default text editor on macOS for all types of source code files. Credits go to https://alexpeattie.com/blog/associate-source-code-files-with-editor-in-macos-using-duti/
#!/usr/bin/env bash
# USAGE: ./set_default_editor.sh "visual studio code"
APP_ID=$(osascript -e "id of app \"$*\"") # eg com.microsoft.VSCode
curl "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml" \
| yq -r "to_entries | (map(.value.extensions) | flatten) - [null] | unique | .[]" \
| xargs -L 1 -I "{}" duti -s "${APP_ID}" {} all
@kabouzeid
kabouzeid / LaravelViteValetDriver.php
Last active April 13, 2021 19:43
~/.config/valet/Drivers/LaravelViteValetDriver.php
<?php
// Code copied from `https://github.com/laravel/valet/blob/d312a588f352c4b5c62b75c4abd1897403b04b76/cli/drivers/LaravelValetDriver.php` (13. April 2021)
class LaravelViteValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
@kabouzeid
kabouzeid / NSManagedObjectExtension.swift
Last active September 9, 2020 17:16
Simple extension to observe CoreData NSManagedObjects, behaves like the observe function in Realm.
//
// NSManagedObjectExtension.swift
//
// Created by Karim Abou Zeid on 10.06.18.
// Copyright © 2018 Karim Abou Zeid Software. All rights reserved.
//
import CoreData
extension NSManagedObject {
SET(MCU "atmega644")
SET(F_CPU "20000000")
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER /usr/local/CrossPack-AVR/bin/avr-gcc)
SET(CMAKE_CXX_COMPILER /usr/local/CrossPack-AVR/bin/avr-g++)
SET(CMAKE_C_FLAGS "-mmcu=${MCU} -DF_CPU=${F_CPU} -O1 -std=gnu99 -Wall")
SET(CMAKE_C_LINK_FLAGS "-mmcu=${MCU}")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
@kabouzeid
kabouzeid / apk2jar.sh
Last active September 16, 2016 21:14
Bash script to quickly decompile an APK. Required tools dex2jar and apktool can be installed via homebrew. Tested on OSX.
#!/bin/bash
apkname=$(basename "$1" .apk)
extractfolder=$PWD/$apkname
unzip -o "$1" classes.dex -d "$extractfolder"
d2j-dex2jar "$extractfolder/classes.dex" -o "$extractfolder/$apkname.jar"
apktool d "$1" -o "$extractfolder/apktool" -f
@kabouzeid
kabouzeid / StopWatch.java
Last active September 12, 2015 12:02
Simple thread safe stop watch for Java.
package com.kabouzeid.gramophone.helper;
/**
* Simple thread safe stop watch.
*
* @author Karim Abou Zeid (kabouzeid)
*/
public class StopWatch {
/**
@kabouzeid
kabouzeid / InternalStorageUtil.java
Created June 22, 2015 10:28
A simple helper class for Android to read and write any serializeable object to the internal storage
package com.kabouzeid.gramophone.util;
import android.content.Context;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;