Skip to content

Instantly share code, notes, and snippets.

View taywils's full-sized avatar
🏠
Working from home

taywils

🏠
Working from home
View GitHub Profile
@taywils
taywils / git_projects.sh
Created October 1, 2018 20:23
Git projects
if echo $PWD | grep -e "./projects"; then
allArgs="$*"
basedir=$PWD
for curdir in */; do
cd $curdir
if test -d ./.git
then
echo "\n\n${curdir}\n\n"
git ${allArgs}
fi
@taywils
taywils / npm-upgrade-global.sh
Created April 19, 2017 00:37
npm upgrade global packages script
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f2)
do
npm -g install "$package"
done
@taywils
taywils / sorted_objects.js
Created April 13, 2017 07:49
Sort a JSON API response array of objects by a unique key
// Example data from a JSON API that returns an array where each object
// has a unique ID. However the API returns the data in a random order.
var myObjects = [
{
data: 'APPL',
id: 33
},
{
data: 'MSFT',
id: 241
@taywils
taywils / Tmux Conf
Last active May 21, 2024 04:53
Tmux Configs
# better prefix key
set -g prefix C-a
bind C-a send-prefix
# better splitting
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# less colourful status
set -g status-bg colour240
set -g status-fg white
# 256 colors support
@taywils
taywils / update_vim_bundles.sh
Last active July 20, 2018 03:28
Shell script that updates all vim pathogen bundles
if echo $PWD | grep -e ".vim/bundle"; then
bdir=$PWD
for curdir in */; do
cd $curdir
echo "\n\n${curdir}\n\n"
git pull
cd $bdir
done
else
echo 'This script must be ran from within your .vim/bundle directory'
@taywils
taywils / JsonMinify.swift
Created October 17, 2016 04:07
Swift JSON Minify
import Foundation
extension String {
public var JSONminify: String {
// http://stackoverflow.com/questions/8913138/
// https://developer.apple.com/reference/foundation/nsregularexpression#//apple_ref/doc/uid/TP40009708-CH1-SW46
let minifyRegex = "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+"
if let regexMinify = try? NSRegularExpression(pattern: minifyRegex, options: .caseInsensitive) {
@taywils
taywils / boostChatServer.cpp
Created November 29, 2014 00:41
Chat server code for my blog article
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<cstdlib>
#include<boost/asio.hpp>
#include<boost/thread.hpp>
#include<boost/asio/ip/tcp.hpp>
@taywils
taywils / boostChatClient.cpp
Last active August 29, 2015 14:10
Boost Chat Client C++ for blog article
#include<iostream>
#include<queue>
#include<string>
#include<cstdlib>
#include<boost/thread.hpp>
#include<boost/bind.hpp>
#include<boost/asio.hpp>
#include<boost/asio/ip/tcp.hpp>
#include<boost/algorithm/string.hpp>
@taywils
taywils / udp_echo_server.c
Created November 11, 2014 05:26
UDP Echo Server Code in C
#define PLATFORM_WINDOWS 1
#define PLATFORM_MAC 2
#define PLATFORM_LINUX 3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_WIN32)
@taywils
taywils / udp_echo_client.c
Created November 10, 2014 00:31
UDP Echo Server Client In C
#define PLATFORM_WINDOWS 1
#define PLATFORM_MAC 2
#define PLATFORM_LINUX 3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_WIN32)