Skip to content

Instantly share code, notes, and snippets.

Avatar

Trever Shick trevershick

View GitHub Profile
View test.cpp
#include <cstring>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
class MyBuf : public std::streambuf {
public:
MyBuf(int maxLength, std::function<void(const char *, int)> callbackFn);
@trevershick
trevershick / CMakeLists.txt
Last active Jan 23, 2019
Simple client and server using libuv and unix domain sockets...
View CMakeLists.txt
set(CMAKE_BUILD_TYPE Debug)
cmake_minimum_required(VERSION 2.8.12)
project(libuv1)
add_definitions("-std=c++11")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(server server.cpp)
View logfile-spec.js
var bucket = "a-bucket";
var filename = "logs/abc";
var event = {
"Records": [
{
"s3": {
"object": {
@trevershick
trevershick / mvncolor.sh
Last active Sep 17, 2015 — forked from katta/mvncolor.sh
Script to add colors to maven output
View mvncolor.sh
#!/usr/bin/env bash
# Formatting constants
export BOLD=`tput bold`
export UNDERLINE_ON=`tput smul`
export UNDERLINE_OFF=`tput rmul`
export TEXT_BLACK=`tput setaf 0`
export TEXT_RED=`tput setaf 1`
export TEXT_GREEN=`tput setaf 2`
export TEXT_YELLOW=`tput setaf 3`
@trevershick
trevershick / diff_from_trunk
Last active Aug 29, 2015
Subversion - Lists out all files that have changes when compared to trunk
View diff_from_trunk
# Lists out all files that have changes when compared to trunk
# this assumes the name of the current directory
# is the name of the folder in ^/trunk/<<folder>>
BASE=$(pwd); BASE=$(basename $BASE); svn diff ^/trunk/$BASE . | grep Index | grep "\." | cut -d " " -f2 | xargs basename | sort | uniq
@trevershick
trevershick / svn_short_log
Last active Sep 12, 2018 — forked from plexus/svn_short_log
svn log, one line per commit
View svn_short_log
#!/usr/bin/awk -f
# Convert the "svn log" output into a one liner format, which is easier to grep
# or use in scripts. Pipe "svn log" into this script
# When we get a line that starts with a revision number, put the data in variables
/^r[0-9]+/ {
rev=$1
user=$3
date=$5
View formatbytes.js
// thanks https://gist.github.com/thomseddon/3511330
function formatBytes(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
@trevershick
trevershick / console.js
Last active Aug 29, 2015
Simple, easy to use console replacement script for use in JsFiddle...
View console.js
if (typeof($) === 'undefined') {
alert('jquery is required');
}
$("body").append($('<div id="console-log"></div>').css({
backgroundColor:'black',
color:'#33FF00',
padding:3
}));
var consoleLineCss = {
View clojure.md

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@trevershick
trevershick / WatchMe.java
Created Oct 16, 2013
Sample code showing how even after a Guava transform, the underlying collection may still be altered.
View WatchMe.java
import static com.google.common.collect.Collections2.transform;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
You can’t perform that action at this time.