Skip to content

Instantly share code, notes, and snippets.

View cworks's full-sized avatar

cworks inc. cworks

View GitHub Profile
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="ys"
# Example aliases
@cworks
cworks / searchjava
Created February 13, 2015 16:32
searchjava alias
alias searchjava="find . -name '*.java' | xargs grep -n "
@cworks
cworks / iffy.sublime-snippet
Created January 14, 2015 14:54
Sublime Text Snippet - iffy
<snippet>
<content><![CDATA[
;(function() {
})();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>iffy</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
@cworks
cworks / JacksonStreamTesting.java
Last active December 31, 2015 05:19
Playing with Jackson Stream parser
package cworks.jackson;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import junit.framework.Assert;
import org.junit.Test;
import java.io.IOException;
#!/usr/bin/env groovy
total = 132;
page_size = 10;
num_pages = (int)Math.ceil(total / page_size);
firstPageOnError = false;
class PageOutOfRangeException extends RuntimeException{};
def pagination(page) {
#!/usr/bin/env groovy
total = 132;
page_size = 10;
num_pages = (int)Math.ceil(total / page_size);
def pagination(page) {
if(page < 0 || page >= num_pages) {
page = 0; // set to first page
}
/*
* We can create, invoke and assign a local-scope anonymous function to
* a variable and client code can use that as the top-level module name.
* One nice thing about this simple pattern is it creates an encapulated
* scope. For example 'names' cannot be accessed from outside the local-scope
* function, clients can only access the functions we return, the return statement
* for all practical purposes defines the modules interface.
*
* Idea for this code borrowed from the wonderful book:
* Eloquent JavaScript by: Marijn Haverbeke
var sendEmail = new Function('to',
'from',
'subject',
'body',
"console.info('Sending email: ' + body)");
sendEmail('buckyATgmail.com',
'nachoATgmail.com',
'warning',
"Don't write code like this!");
emitted: [1367983439273,83]
debug - websocket writing 5:::{"name":"sample","args":[{"x":1367983439767,"y":89}]}
emitted: [1367983439767,89]
debug - websocket writing 5:::{"name":"sample","args":[{"x":1367983440274,"y":97}]}
emitted: [1367983440274,97]
debug - websocket writing 5:::{"name":"sample","args":[{"x":1367983440769,"y":39}]}
emitted: [1367983440769,39]
debug - websocket writing 5:::{"name":"sample","args":[{"x":1367983441275,"y":53}]}
emitted: [1367983441275,53]
debug - websocket writing 5:::{"name":"sample","args":[{"x":1367983441771,"y":32}]}