Skip to content

Instantly share code, notes, and snippets.

View jerrymarino's full-sized avatar

Jerry Marino jerrymarino

View GitHub Profile
@jerrymarino
jerrymarino / .vimrc
Created April 25, 2017 16:44
Minimalist vimrc for vim with tmux
" Basic setup
let mapleader=","
set clipboard=unnamed
execute pathogen#infect()
syntax on
@jerrymarino
jerrymarino / .tmux.conf
Created April 25, 2017 16:49
Minimal vim inspired tmux conf for OSX
# Use ctrl-a for prefix
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix
# OSX Fix copy and paste. If on ZSH replace bash with ZSH
set-option -g default-command "reattach-to-user-namespace -l bash"
# improve colors
set -g default-terminal "screen-256color"
@jerrymarino
jerrymarino / beast_http_server_non_blocking_gcd.cpp
Created May 2, 2017 07:08
Example of beast http with "long running" operations and Grand Central Dispatch
/**
* Beast HTTP server example with long running operations and lib dispatch.
*
* Note: Assume that we are calling dispatch_main() after running the server
*/
#include "file_body.hpp"
#include "mime_type.hpp"
#include <beast/http.hpp>
@jerrymarino
jerrymarino / PythonVimPluginExample.vim
Created May 22, 2018 04:44
How to setup a vim plugin using python 2 or python 3
" Basic example of using Python with vim
" This is basic vim plugin boilerplate
let s:save_cpo = &cpo
set cpo&vim
function! s:UsingPython3()
if has('python3')
return 1
endif
@jerrymarino
jerrymarino / gist:cce9767cb4dda276ef86793b4a6d2288
Created June 10, 2018 16:34
Insert content into vim buffer programmatically
" Insert content into vim buffer programmatically
" Exe:
:exe ":normal i" . "some"
" FeedKeys:
:call feedkeys("i". "some")
@jerrymarino
jerrymarino / UnsafeCallable.swift
Created June 17, 2018 04:06
How to call Swift functions by address
func helloWorld(a: Int) {
print("Hello world!", 1)
}
// Converting to an address:
// - Erase the type to an Object so swift doesn't complain
// - Bitcast
var erasedFunc = helloWorld as AnyObject
let address = unsafeBitCast(erasedFunc, to: Int.self)
@jerrymarino
jerrymarino / gist:9de95355173b77b559e388a2682fec65
Created June 23, 2018 18:00
Transform and compile raw SIL
#!/bin/bash
# Path to the swift compiler
SWIFT=(~/myswift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift)
SWIFTC=(~/myswift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc)
IFS='' read -d '' -r SOURCE <<"EOF"
struct Some {
let attr = 0
}
@jerrymarino
jerrymarino / gist:b7b8bfa7a3779ddf4f9662efc1c133f9
Created July 1, 2018 18:42
[Bash 1 liner] Delete all git branches besides the current one
# List all of the current branches - invert * as it represents the current one
# and will cause many issues
for B in $(git branch --list | grep --invert '*'); do git branch -D $B; done
# Additional ideas are cleaning up the remote ( i.e. ):
for B in $(git branch -a --list | grep --invert '*'); do git push origin : $B; done
@jerrymarino
jerrymarino / clean_modules.sh
Created September 6, 2018 00:54
Clearing clang's implicit module map for safe, incremental module enabled builds
#!/bin/bash
# This program cleans out the implcit module cache and modulemaps.
# Remove modulemaps to prevent loading lingering invalid modulemaps
# ( Genfiles is not cleared for each incremental build )
set -e
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORKSPACE_DIR="$SCRIPTPATH/../"
EXEC_ROOT=$($WORKSPACE_DIR/tools/bazelwrapper info execution_root)
@jerrymarino
jerrymarino / SwiftBinaryDemangler.sh
Created January 30, 2019 19:49
Demangle the entire symbol table of a swift binary
nm __BINARY__ | awk '{ print $3 }' | xargs xcrun swift-demangle {} \; | less