Skip to content

Instantly share code, notes, and snippets.

import java.util.Random;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Stopwatch;
/**
* Sample example demonstrating usage of Stopwatch API of Google Guava.
*
* @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Stopwatch.html">Guava Stopwatch</a>
*/
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
<project name="migrations">
<target name="prefix-new-migrations">
<foreach target="rename-file" param="the-file">
<path>
<!-- The hardcoded directory containing the migrations -->
<fileset dir="./src/db/migrations" casesensitive="no" includes="*.sql">
<!-- Exclude any migration files which have already been prefixed -->
<not>
<filename regex="\d+__.*" casesensitive="true"/>
DELIMITER $$
DROP PROCEDURE IF EXISTS add_email_address_column_to_customers_table $$
-- Create the stored procedure to perform the migration
CREATE PROCEDURE add_email_address_column_to_customers_table()
BEGIN
-- Add the email_address column to the customers table, if it doesn't already exist
@timoyuen
timoyuen / gist:4ffaca4cd698fdf07d31
Created September 4, 2014 02:06
sed the fix control A and add a line in between
tail -f FIX.log | sed -e 's/^A/ /g' -e 'G'
<oauth:client token-services-ref="oauth2TokenServices" />
<beans:bean id="oauth2TokenServices"
class="org.springframework.security.oauth2.consumer.token.InMemoryOAuth2ClientTokenServices" />
<oauth:resource id="cv" type="authorization_code"
clientId="foo" accessTokenUri="http://localhost:8080/cv/oauth/authorize"
userAuthorizationUri="http://localhost:8080/cv/oauth/user/authorize" />
<beans:bean id="cvService" class="org.springsource.oauth.CVServiceImpl">
@timoyuen
timoyuen / gist:31cad394d2ef62430668
Created October 14, 2014 02:19
cron every week
30 2 8-14,22-28 * * test $(date +%u) -eq 1 && sh /root/clone_to_sandbox.sh
http://www.nicovs.be/schedule-cron-jobs-to-run-every-2-weeks/
or
3 2 1,15 * * sh /root/clone_to_sandbox.sh
ssh -p 2222 -R 2204:192.168.7.176:2204 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -o IdentitiesOnly=yes -i ~/.vagrant.d/insecure_private_key vagrant@127.0.0.1

How to add environment variables to nginx.conf

This is the hack approach to adding environment variables to the nginx configuration files. As with most Google results for this search, the reason is Docker.

The setup

I intended to deploy two Docker containers.