Skip to content

Instantly share code, notes, and snippets.

View thread_last_currying.clj
;;
;; Example of thread last macro ->> and partial function application
;;
(defn header [this] {:head this})
(->> (header 1) :head ((partial + 1)))
;; => 2
(->> (header 3) :head ((partial - 1)))
;; => -2
@fredrick
fredrick / cheatsheet.R
Last active Aug 29, 2015
R Statistics Cheetsheet
View cheatsheet.R
library(ggplot2)
library(plyr)
## Graphing
# Histogram of columnName in someDataFrame, ordered in descending frequency
# from left to right.
ggplot(someDataFrame, aes(x=reorder(columnName,columnName,function(x)-length(x)))) +
geom_bar() +
xlab("X Label") +
@fredrick
fredrick / config.txt
Created Apr 6, 2015
Presto VM options
View config.txt
-ea -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties -Dhive.metastore.uri=thrift://localhost:9083
View KRUI - FFMP3
<!-- BEGINS: AUTO-GENERATED FFMP3 CODE -->
<object width="180" height="60" bgcolor="#FFFFFF">
<param name="movie" value="ffmp3-config.swf" />
<param name="flashvars" value="url=http://remote.krui.fm:8000/listen&lang=en&codec=mp3&volume=100&tracking=true&skin=ffmp3-mcclean.xml&title=KRUI" />
<param name="wmode" value="window" />
<param name="scale" value="noscale" />
<embed src="ffmp3-config.swf" flashvars="url=http://remote.krui.fm:8000/listen&lang=en&codec=mp3&volume=100&tracking=true&skin=ffmp3-mcclean.xml&title=KRUI" width="180" scale="noscale" height="60" wmode="window" bgcolor="#FFFFFF" type="application/x-shockwave-flash" />
</object>
<!-- ENDS: AUTO-GENERATED FFMP3 CODE -->
@fredrick
fredrick / padInt.js
Created Dec 28, 2010
Converts integers such as '1' to strings "01"
View padInt.js
function padInt(number){
if (parseInt(number) < 10){
return "0" + parseInt(number).toString();
} else {
return number.toString();
}
}
@fredrick
fredrick / Graph.js
Created Feb 28, 2011
Example: objects/prototypes in JavaScript
View Graph.js
/*
JavaScript Stream data client and graph renderer
*/
jQuery(document).ready(function() {
function Graph(type) {
/*
Graph class
Override properties to modify graph appearance before invoking the render() method
*/
this.category = type;
@fredrick
fredrick / seat-Object-blender.py
Created Mar 10, 2011
Object instantiation of a data type blender
View seat-Object-blender.py
test = Test(
string='test-554e4b55e8cc57f39f16f335b0a63825',
integer=123,
float=3.14159265,
array=['thing 1', 'thing 2', 'thing 3'],
tuple=('string', 123, 3.14159265),
dictionary={'this 1': 'that 1', 'this 2': 'that 2'},
tuples_in_array=[('string', 123, 3.14159265), ('string', 456, 3.14159265)],
arrays_in_tupple=(['thing 1', 'thing 2', 'thing 3'], ['thing 4', 'thing 5', 'thing 6']),
complex_nested_mixed_data_types=(
@fredrick
fredrick / stub.py
Created Mar 15, 2011
Dynamically define object variables/methods at instantiation (quick mock)
View stub.py
class Stub(object):
def __init__(self, **kwargs):
for key in kwargs:
setattr(self, key, kwargs[key])
@fredrick
fredrick / pyinotify-issue2.log
Created Mar 17, 2011
pyinotify event dump, Missing IN_CREATE events
View pyinotify-issue2.log
1300383220 : <Event dir=False mask=0x100 maskname=IN_CREATE name=latest.tar.gz path=/home/fgaloso/test pathname=/home/fgaloso/test/latest.tar.gz wd=1 >
1300383225 : <Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=latest.tar.gz path=/home/fgaloso/test pathname=/home/fgaloso/test/latest.tar.gz wd=1 >
1300383241 : <Event dir=True mask=0x40000100 maskname=IN_CREATE|IN_ISDIR name=wordpress path=/home/fgaloso/test pathname=/home/fgaloso/test/wordpress wd=1 >
1300383241 : <Event dir=False mask=0x100 maskname=IN_CREATE name=wp-rss.php path=/home/fgaloso/test/wordpress pathname=/home/fgaloso/test/wordpress/wp-rss.php wd=2 >
1300383241 : <Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=wp-rss.php path=/home/fgaloso/test/wordpress pathname=/home/fgaloso/test/wordpress/wp-rss.php wd=2 >
1300383241 : <Event dir=False mask=0x100 maskname=IN_CREATE name=wp-blog-header.php path=/home/fgaloso/test/wordpress pathname=/home/fgaloso/test/wordpress/wp-blog-header.php wd=2 >
1300383241 : <Event dir=False mask=0x8 mask
@fredrick
fredrick / distinct-value-couchdb.js
Created Mar 28, 2011
Way to return unique distinct values by a given key?
View distinct-value-couchdb.js
'key1' => 'somevalue'
'key1' => 'somevalue'
'key2' => 'anotherval'
'key2' => 'andanother'
'key2' => 'andanother'
/*
Way to return unique distinct values by a given key?
For example:
?key="key1" would return ['somevalue']
You can’t perform that action at this time.