Skip to content

Instantly share code, notes, and snippets.

Kenny Cason kennycason

View GitHub Profile
@kennycason
kennycason / BinaryFileInputFormat.java
Created Jan 3, 2019
Hadoop IO - BinaryFileInputFormat
View BinaryFileInputFormat.java
package com.kennycason.hadoop.io;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
/** An {@link InputFormat} for reading binary data (byte[]) */
public class BinaryFileInputFormat extends FileInputFormat<NullWritable, ImmutableBytesWritable> {
@kennycason
kennycason / getMonthExample1.js
Last active Apr 7, 2018
getMonth.js (example)
View getMonthExample1.js
function monthName() {
switch (new Date().getMonth()) {
case 0:
return "January";
case 1:
return "February";
case 2:
return "March";
case 3:
return "April";
View gist:01da696d570024c61fa969ae79cf9dee
print("hello, world")
# list
friends = ['john', 'pat', 'gary', 'michael']
print(len(friends))
for f in friends:
print("hello " + f)
# map / dictionary
friends2 = {
View README.md

Run

g++ main.cpp chmod +x a.out ./a.out

@kennycason
kennycason / lrss.py
Created Aug 9, 2017
Longest Repeated SubString
View lrss.py
def lrss(s):
slen = len(s)
for l in range(slen - 1, 1, -1): # the length of the string, go from max to min, decrementing range
print "l=" + str(l)
# there is a bit of redundancy in the i/j iterations as they double check each other
# e.g. when i < j and j > i
for i in range(0, slen - l + 1): # tracks position of the iterations
print " i=" + str(i)
for j in range(0, slen - l + 1): # tracks position of the iterations
if i == j: continue # if i == j , then it's the same index in the string
View Banana.java
public class Banana {
public static void main(final String[] args) {
assert contains("banana", "b");
assert contains("banana", "ana");
assert contains("banana", "na");
assert contains("banana", "banana");
assert !contains("banana", "gx");
assert !contains("banana", "");
assert !contains("", "ana");
View JsonApiTest.java
package com.simplymeasured.cls.bll;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.github.jasminb.jsonapi.JSONAPIDocument;
import com.github.jasminb.jsonapi.ResourceConverter;
import com.github.jasminb.jsonapi.SerializationFeature;
import com.github.jasminb.jsonapi.annotations.Id;
import com.github.jasminb.jsonapi.annotations.Relationship;
import com.github.jasminb.jsonapi.annotations.Type;
@kennycason
kennycason / response.json
Created Jan 18, 2017
Sample Tumblr API Response.json
View response.json
{
"meta":{
"status":200,
"msg":"OK"
},
"response":[
{
"blog_name":"tazmilyfarmboy",
"id":156044133478,
"post_url":"http://tazmilyfarmboy.tumblr.com/post/156044133478/super-old-ace-samus-for-ikelikestoast-i-never",
@kennycason
kennycason / ParallelStreamSaturationTest.java
Created Sep 20, 2016
Demonstrate Java Parallel streams fall back to main thread in the event that all workers in common fork join pool are saturated.
View ParallelStreamSaturationTest.java
package com.simplymeasured.gus.controller;
import java.util.Arrays;
/**
* Created by kenny on 9/20/16.
*
* Demonstrate Java Parallel streams fall back to main thread in the event that all workers in common fork join pool
* are saturated.
*/
@kennycason
kennycason / sawsalag.php
Last active Apr 14, 2016
Sawsalag.php - Deciphered
View sawsalag.php
<?php
$bliss ='s';
$eradicate='F';
$canvassing= '_';
$booms = '>';
$longer= 'NLs';
$chi=';';
$filthiest= 'O';
$cadent = 'r';
You can’t perform that action at this time.