Skip to content

Instantly share code, notes, and snippets.

View jerrymarino's full-sized avatar

Jerry Marino jerrymarino

View GitHub Profile
@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 / .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 / .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 / vim_and_tmux_on_osx.md
Created April 25, 2017 16:41
Setting up vim and tmux on OSX

Upgrade Vim to MacVim

Firstly, install macvim and get the keyboard working

Note: easiest way here is to use macvim from brew

brew install macvim --with-override-system-vim

In .vimrc

@jerrymarino
jerrymarino / run_ios_sim.sh
Last active October 21, 2025 15:49
Build and run an iOS application on the simulator from the command line
#!/bin/bash
# run_ios_sim builds and runs an iOS app on the simulator
#
# It is designed to replicate the behavior of "Run" in Xcode and assumes basic
# xcodebuild usage.
#
# USAGE:
# export IOS_SIM_UDID=342F9A20-DF48-41A9-BE60-C6B35F47E97F; \
# export BUNDLE_IDENTIFIER=a.Some; \
# export APP_PATH=$PWD/Build/Debug-iphonesimulator/$APP_NAME.app \
@jerrymarino
jerrymarino / vim script
Created April 19, 2017 07:14
Jump to semantic placeholders in vim
function! Generate_placeholder_pattern()
return '<#\%(T##\)\?\%([^#]\+##\)\?\([^#]\+\)#>'
endfunction
function! Jump_to_placeholder()
if &filetype !=# 'swift'
return ''
end
if !Check_placeholder_existence()
# YouCompleteMe configuration for OSX development
import os
import ycm_core
flags = [
'-resource-dir',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0',
'-isysroot',
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk',
'-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include',
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"
%%% @author Sergey Prokhorov <[email protected]>
%%% @copyright (C) 2013, Sergey Prokhorov
%%% @doc
%%% Walker alias method - efficient random selection with defined probabilities.
%%% <http://en.wikipedia.org/wiki/Alias_method>
%%%
%%% > ProbabilityValueList = [{10, a}, {20, b}, {30, c}, {40, d}],
%%% > WalkerVectors = walker_alias:build(ProbabilityValueList),
%%% > RandomValue = walker_alias:choice(WalkerVectors).
%%%
@jerrymarino
jerrymarino / ecmascript-rough-object-size
Created August 4, 2013 02:02
ECMAScript object size
function roughSizeOfObject( object ) {
var objectList = [];
var stack = [ object ];
var bytes = 0;
while ( stack.length ) {
var value = stack.pop();
if ( typeof value === 'boolean' ) {