Skip to content

Instantly share code, notes, and snippets.

@mattupstate
mattupstate / cloud-context-config
Created April 19, 2011 14:47
Easily get your cloud environment properties in your Spring context initializer
package net.nobien.cloudfoundry.example.config;
import java.util.Properties;
import org.cloudfoundry.runtime.env.CloudEnvironment;
import org.cloudfoundry.runtime.env.CloudEnvironmentPropertiesFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.core.env.ConfigurableEnvironment;
@jimjeffers
jimjeffers / html5VideoAspectRatioAdjustment.coffee
Created September 15, 2011 13:24
Breaking the HTML5 Video Aspect Ratio
# Just an example.
# @video is a direct reference to a '<video>' element.
# $() is assuming jQuery is being used in this example.
@video.addEventListener("loadedmetadata", (event) =>
actualRatio = @video.videoWidth/@video.videoHeight
targetRatio = $(@video).width()/$(@video).height()
adjustmentRatio = targetRatio/actualRatio
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})")
)
@marcoleong
marcoleong / bootstrap-scrollspy-horizontal.js
Created February 27, 2012 09:22
Modified bootstrap-scrollspy.js to support horizontal scroll.
/* =============================================================
* bootstrap-scrollspy.js v2.0.1
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
* =============================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed 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
*
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 23, 2024 15:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@smougenot
smougenot / A_Logstash.conf
Created July 26, 2012 13:59
Logstash Multiline Filter for Java Stacktrace (tested on field)
# stacktrace java as one message
multiline {
#type => "all" # no type means for all inputs
pattern => "(^.+Exception: .+)|(^\s+at .+)|(^\s+... \d+ more)|(^\s*Caused by:.+)"
what => "previous"
}
@christophercurrie
christophercurrie / gist:3841860
Created October 5, 2012 19:32
Guice for Dropwizard
@Override
public ServletContainer getJerseyContainer(DropwizardResourceConfig resourceConfig,
MyServiceConfig serviceConfig) {
// I like having a root module, but you can use as many as you like
final Injector injector = Guice.createInjector(new MyServiceModule(serviceConfig));
return new GuiceContainer(injector) {
@Override
public ResourceConfig getDefaultResourceConfig(Map<String,Object> props, WebConfig webConfig) {
@cemo
cemo / rate_limit.js
Created November 21, 2012 20:07 — forked from mattheworiordan/rate_limit.js
Rate limiting function calls with JavaScript and Underscore.js
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
@juddflamm
juddflamm / gist:5391938
Last active July 13, 2018 01:08
Enabling 2 Way SSL Client Service Calls from within Dropwizard. To do so, you need to load your keystore and truststore and configure HttpClient to us them for HTTPS calls. In this case, my keystore and truststore are the same file with the same password. (Thanks to Coda Hale for an initial solution)
//First create the httpClient in Dropwizard's run method as documented
final HttpClient httpClient = new HttpClientBuilder().using(configuration.getHttpClient()).build();
try {
//Create KeyStore obejcts for both the keystore and truststore
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore truststore = KeyStore.getInstance(KeyStore.getDefaultType());
//Then load the actual keystore/truststore file(s), they are the same file in my case
keystore.load(new FileInputStream(configuration.getKeyStore()), configuration.getKeyStorePassword().toCharArray());
@bmfurtado
bmfurtado / cssh.applescript
Last active July 28, 2020 15:44
Create multiple SSH sessions in split panes on iTerm2 and enable key broadcasting.
Moved to: https://github.com/bmfurtado/iterm2-cssh
@gkossakowski
gkossakowski / MemoryProbe.java
Created June 3, 2013 20:56
YourKit probe class that allows one to capture memory snapshots after certain phases has run in the Scala compiler.
import com.yourkit.probes.*;
import com.yourkit.api.*;
@MethodPattern("scala.tools.nsc.Global$Run:advancePhase()")
public class MemoryProbe {
public static void onEnter(@This scala.tools.nsc.Global.Run run) {
scala.reflect.internal.Phase patmatPhase = run.phaseNamed("patmat");
scala.reflect.internal.Phase postErasurePhase = run.phaseNamed("posterasure");
scala.reflect.internal.Phase icodePhase = run.phaseNamed("icode");