Skip to content

Instantly share code, notes, and snippets.

View T1T4N's full-sized avatar
👽

Robert Armenski T1T4N

👽
View GitHub Profile
@T1T4N
T1T4N / uac_bypass.c
Created October 17, 2016 00:04 — forked from Cr4sh/uac_bypass.c
void TestCopy()
{
BOOL cond = FALSE;
IFileOperation *FileOperation1 = NULL;
IShellItem *isrc = NULL, *idst = NULL;
BIND_OPTS3 bop;
SHELLEXECUTEINFOW shexec;
HRESULT r;
do {
@T1T4N
T1T4N / gist:a735f4f5239fb9d9192a7839d5445774
Created October 17, 2016 00:04 — forked from Cr4sh/gist:fe910f0d1b0559efd43d
Dynamically finding sys_call_table on Linux x86_64 systems
void **find_sys_call_table(void *kernel_addr, int kernel_size)
{
/*
Check for the system_call_fastpath() signature, hand-written piece of
assembly code from arch/x86/kernel/entry_64.S:
ja badsys
mov rcx, r10
call sys_call_table[rax * 8]
mov [rsp + 20h], rax
@T1T4N
T1T4N / gksudo.applescript
Last active December 14, 2016 08:49
gksudo implementation for macOS
#!/usr/bin/osascript
on convertListToString(theList, theDelimiter)
set output to (item 1 of theList)
if (count theList) > 1 then
set theList to items 2 through (count theList) of theList
repeat with listItem in theList
set parsedItem to listItem
if space is in listItem then
set parsedItem to (quoted form of listItem)
@T1T4N
T1T4N / .tmux.conf
Last active January 10, 2018 07:51
tmux 2.5 emulate scrolling by sending up/down keys for specified commands
# Emulate scrolling by sending up and down keys if these commands are running in the pane
tmux_commands_with_legacy_scroll="'nano less more man'"
bind -n WheelUpPane if "[[ #{tmux_commands_with_legacy_scroll} =~ #{pane_current_command} ]]" "select-pane -t = ; send-keys Up" 'if-shell -F -t = "#{mouse_any_flag} || #{pane_in_mode}" "send-keys -M" "copy-mode -et="'
bind -n WheelDownPane if "[[ #{tmux_commands_with_legacy_scroll} =~ #{pane_current_command} ]]" "select-pane -t = ; send-keys Down" 'if-shell -F -t = "#{mouse_any_flag} || #{pane_in_mode}" "send-keys -M" "copy-mode -et="'
@T1T4N
T1T4N / xcode_dyn_dev_dir.sh
Created August 7, 2017 14:34
Specify Xcode developer dir by version
DEVELOPER_DIR=$(XCODE_VER=9; TMP_RET=$(ls "/Applications" | grep -E "Xcode-?${XCODE_VER}.*\.app" | head -n 1 | xargs -I {} echo "/Applications/{}/Contents/Developer"); [[ ${TMP_RET} ]] || TMP_RET=$(/usr/bin/xcrun xcode-select -p); echo $TMP_RET) eval echo '$DEVELOPER_DIR'
@T1T4N
T1T4N / Collection+SafeSubscript.swift
Created August 8, 2017 09:29
Safe collection indexing that returns an optional if index out of bounds
extension Collection {
/// Returns the element at the specified index iff it is within bounds, otherwise nil.
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
@T1T4N
T1T4N / brewUpdateAll.sh
Last active January 9, 2018 08:41
brew update all packages by temporary unpinning
# cd /usr/local/Homebrew
# brew update && git stash pop
# BREW_PINNED=$(brew list --pinned | sort | tr '\n' ' ') sh -c '_cleanup() { brew cleanup && brew cask cleanup && brew pin $BREW_PINNED; }; trap _cleanup INT; echo "Pinned: $BREW_PINNED"; brew unpin $BREW_PINNED; brew upgrade; _cleanup'
#OR
(BREW_PINNED=($(brew list --pinned | sort | tr '\n' ' ')); function _cleanup() { brew cleanup && brew cask cleanup; brew pin "$BREW_PINNED[@]"; }; trap _cleanup INT; echo "Pinned: $BREW_PINNED"; brew unpin "$BREW_PINNED[@]"; brew upgrade; _cleanup)
@T1T4N
T1T4N / retain_count.m
Created September 8, 2017 12:28
Get retain count
NSLog(@"RC: %ld", CFGetRetainCount((__bridge CFTypeRef)m_object));
@T1T4N
T1T4N / bash_logging.sh
Last active January 9, 2018 08:41
Simple bash logging to a file
#!/usr/bin/env bash
readonly LOG_FILE="/tmp/$(basename "$0").log"
log_i() { echo "[INFO] $*" | tee -a "$LOG_FILE" >&2; }
log_w() { echo "[WARNING] $*" | tee -a "$LOG_FILE" >&2; }
log_e() { echo "[ERROR] $*" | tee -a "$LOG_FILE" >&2; }
log_f() { echo "[FATAL] $*" | tee -a "$LOG_FILE" >&2; return 1; }
@T1T4N
T1T4N / restore_shell_opts.sh
Created September 15, 2017 09:33
Save shell options (set command) and restore them
local -r SAVED_OPTIONS=$(set +o)
source "script_that_modifies_shell_options.sh"
set +x; eval "${SAVED_OPTIONS}"