Skip to content

Instantly share code, notes, and snippets.

* template[/tmp/statsd/debian/changelog] action create[2013-02-18T21:44:06+00:00] INFO: Processing template[/tmp/statsd/debian/changelog] action create (statsd::default line 38)
[2013-02-18T21:44:06+00:00] INFO: template[/tmp/statsd/debian/changelog] backed up to /var/chef/backup/tmp/statsd/debian/changelog.chef-20130218214406
[2013-02-18T21:44:06+00:00] INFO: template[/tmp/statsd/debian/changelog] updated content
- update template[/tmp/statsd/debian/changelog] from a0de22 to b03a05
--- /tmp/statsd/debian/changelog 2013-02-18 21:43:46.000000000 +0000
+++ /tmp/chef-rendered-template20130218-2815-yw1xz1-0 2013-02-18 21:44:06.000000000 +0000
@@ -1,19 +1,5 @@
-statsd (0.0.3) unstable; urgency=low
+statsd (0.5.0) unstable; urgency=low
package com.lol.testy
import com.twitter.finatra._
object App {
class ExampleApp extends Controller { /** * Basic Example * * curl http://localhost:7070/hello => "hello world" */ get("/") { request => render.plain("hello world").toFuture } /** * Route parameters * * curl http://localhost:7070/user/dave => "hello dave" */ get("/user/:username") { request => val username = request.routeParams.getOrElse("username", "default_user") render.plain("hello " + username).toFuture } /** * Setting Headers * * curl -I http://localhost:7070/headers => "Foo:Bar" */ get("/headers") { request => render.plain("look at headers").header("Foo", "Bar").toFuture } /** * Rendering json * * curl -I http://localhost:7070/headers => "Foo:Bar" */ get("/data.json") { request => render.json(Map("foo" -> "bar")).toFuture } /** * Query params * * curl http://localhost:7070/search?q=foo => "no res
##
# dircycle plugin: enables cycling through the directory
# stack using Ctrl+Shift+Left/Right
setopt autopushd
eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
zle -N insert-cycledleft
bindkey "\e[1;6D" insert-cycledleft
eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q -0'; zle accept-line }"
zle -N insert-cycledright
get("/main.:format") { request =>
respondTo(request) {
case _:Json => render.json({"foo" -> "bar"}).toFuture
case _:Txt => render.plain("lol").toFuture
}
}
@capotej
capotej / HeaderParser.java
Last active December 10, 2015 20:38
A generic http header parser, lifted from Apache's FileUpload class.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@capotej
capotej / load-test.rb
Last active December 10, 2015 07:18
basic skeleton for executing tasks in parallel in jruby
require 'java'
java_import 'java.util.concurrent.ThreadPoolExecutor'
java_import 'java.util.concurrent.TimeUnit'
java_import 'java.util.concurrent.LinkedBlockingQueue'
java_import 'java.util.concurrent.FutureTask'
java_import 'java.util.concurrent.Callable'
java_import 'java.util.concurrent.Executors'
### SETTINGS
@capotej
capotej / set-title-tab.zsh
Created December 17, 2012 19:05
sets title tab intelligently in zsh/iterm2
#!/bin/zsh -f
# This is the successor to settab and settitle functions (as well as the chpwd function).
# It avoids the explicit definition and use of special functions such as
# chpwd, precmd, preexec, instead setting appropriate arrays. This is to prevent conflicts
# with user's prompt functions and so forth.
# This is designed to put by default the computer name and whole directory path
# into the title bar (and if availble) the $PWD and penultimate directory
# in the tab. Also enables transient display of a running command (eg vim).
{
"bold_folder_labels": true,
"caret_style": "wide",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"dictionary": "Packages/Language - English/en_US.dic",
"draw_indent_guides": false,
"draw_white_space": "none",
"ensure_newline_at_eof_on_save": true,
"file_exclude_paterns":
[
function prompt_git_branch() {
if [ ! -e .git ]; then
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
fi
}
require 'open-uri'
failed = []
File.read('File.txt').lines.each do |x|
begin
sleep 1
st = Time.now.to_f
puts "#{x}: #{open(x).status} in #{(et - st)}"
et = Time.now.to_f
rescue