Skip to content

Instantly share code, notes, and snippets.

@jeromyanglim
jeromyanglim / example-r-markdown.rmd
Created May 17, 2012 04:23
Example of using R Markdown
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown)
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for
[reproducible analysis](http://stats.stackexchange.com/a/15006/183).
Specifically, this post
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and
(5) discusses the implications of R Markdown.
@irasally
irasally / run.sh
Created October 3, 2012 05:07
[mongodb] run command 'compact' for all collections
#!/bin/sh
mongo localhost:27017/mongo run_command.js
mongo localhost:27018/mongo run_command.js
mongo localhost:27019/mongo run_command.js
# if you don't need connection infomation etc., use --quiet option.
# http://www.mongodb.org/display/DOCS/--quiet
@francisdb
francisdb / MicrosoftJsonDateDeserializer.scala
Last active November 17, 2016 00:02
Scala Jackson json deserializer for Microsoft json date format to joda DateTime
import com.fasterxml.jackson.databind.{DeserializationContext, JsonDeserializer}
import org.joda.time.{DateTimeZone, DateTime}
import com.fasterxml.jackson.core.JsonParser
import java.io.IOException
class MicrosoftJsonDateDeserializer extends JsonDeserializer[DateTime] {
val Pattern = """\/Date\((\d+)([-+]\d+)?\)\/""".r
def deserialize(jsonParser: JsonParser, deserializationContext: DeserializationContext): DateTime = {
val dateString = jsonParser.getText
@jelies
jelies / AutowiringSpringBeanJobFactory.java
Last active February 11, 2025 08:39
Quartz (2.1.6) java config with spring (3.2.1). Using a SpringBeanJobFactory to automatically autowire quartz classes.
package com.jelies.spring3tomcat7.config.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
/**
* This JobFactory autowires automatically the created quartz bean with spring @Autowired dependencies.
@edalorzo
edalorzo / Cons.java
Created March 11, 2013 16:48
Java Infinite Streams
import java.util.function.Supplier;
public class Cons<T> implements Stream<T>{
private final T head;
//stream thunk
private final Supplier<Stream<T>> tail;
public Cons(T head, Supplier<Stream<T>> tail) {
this.head = head;
@mikedamage
mikedamage / mongo-stats.sh
Created May 21, 2013 19:32
Mongo collection stats script
#!/bin/bash
#
# = Mongo Collection Stats Script
database=${1:-test}
mongo --quiet --eval '
var collections = db.getCollectionNames();
print("Collection Count Size StorageSize AvgObjSize nIndexes");
@garyrussell
garyrussell / ContainerRetryTests-context.xml
Last active December 13, 2022 19:03
Spring AMQP Container Retry Example - uses the default retry template (3 attempts and no recovery - the failed message is just logged at WARN level). Inject a `RetryTemplate` into the factory bean for more options.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<rabbit:connection-factory id="connectionFactory" />
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"

case studies

learning… haskell math how generators work in python french how to draw an instrument

@mattmight
mattmight / pythedral.py
Created December 2, 2014 22:48
Church Python
# Void
VOID = lambda void: void
# Booleans / Conditionals
IF = lambda c: lambda t: lambda f: c(t)(f)
@johnynek
johnynek / AliceInAggregatorLand.scala
Last active January 24, 2024 19:38
A REPL Example of using Aggregators in scala
/**
* To get started:
* git clone https://github.com/twitter/algebird
* cd algebird
* ./sbt algebird-core/console
*/
/**
* Let's get some data. Here is Alice in Wonderland, line by line
*/