Skip to content

Instantly share code, notes, and snippets.

View cedricvidal's full-sized avatar

Cedric Vidal cedricvidal

View GitHub Profile
@cedricvidal
cedricvidal / Vagrantfile
Created February 6, 2014 00:19
Ubuntu Raring Vagrantfile
Vagrant::Config.run do |config|
config.vm.box = "raring"
config.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box"
config.vm.share_folder("vagrant-root", "/vagrant", ".")
config.vm.customize ["modifyvm", :id, "--memory", 2048]
end

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
import junit.framework.TestCase;
import org.junit.runner.RunWith;
import org.junit.runners.AllTests;
import junit.framework.TestSuite;
@RunWith(AllTests.class)
public final class MasterTester {
public static TestSuite suite() {
TestSuite suite = new TestSuite();
@cedricvidal
cedricvidal / remote-docker-ssh-shellinit.sh
Last active August 31, 2015 09:20
Configure remote docker over SSH
HOST=user@host
# Make sure socat is installed on remote before starting tunnel
ssh $HOST socat -V | grep "socat version" | cat 1>&2
# Start tunnel
echo "starting tunnel" 1>&2
(socat "UNIX-LISTEN:/tmp/$HOST-docker.sock,reuseaddr,fork" "EXEC:'ssh -kTax $HOST socat STDIO UNIX-CONNECT\:/var/run/docker.sock'" 2>&1 | >&2 xargs echo) &
# Tell docker
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
<title>
My Exhibit's Title
</title>
<link href="exhibit-data.js" type="application/json" rel="exhibit/data">
<script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" type="text/javascript">
</script>
@cedricvidal
cedricvidal / eclipse-java-templates.xml
Created October 4, 2012 12:44
Eclipse Java Templates
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<templates>
<template autoinsert="true" context="java-members" deleted="false" description="Slf4j Logger" enabled="true" name="log">private static ${loggerType:newType(org.slf4j.Logger)} log = ${factoryType:newType(org.slf4j.LoggerFactory)}.getLogger(${enclosing_type}.class);
</template>
<template autoinsert="true" context="java-members" deleted="false" description="Slf4j Instance level Logger" enabled="true" name="log-instance">private ${loggerType:newType(org.slf4j.Logger)} log = ${factoryType:newType(org.slf4j.LoggerFactory)}.getLogger(this.getClass());&#13;
&#13;
public void setLogger(${loggerType} logger) {&#13;
this.log = logger;&#13;
@cedricvidal
cedricvidal / gist:3833314
Created October 4, 2012 12:42
Eclipse Java Template Slf4j Logger
private static ${loggerType:newType(org.slf4j.Logger)} log = ${factoryType:newType(org.slf4j.LoggerFactory)}.getLogger(${enclosing_type}.class);
@cedricvidal
cedricvidal / gist:4030721
Created November 7, 2012 10:18
JMX Remote Unsecured
-Dcom.sun.management.jmxremote.port=<bind_port>
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=<host_bind_ip>
@cedricvidal
cedricvidal / colorizer.pl
Created November 8, 2012 10:51
Simple PERL colorizer
#!/usr/bin/perl -w
use Term::ANSIColor;
use POSIX qw(strftime);
use Getopt::Long;
Getopt::Long::Configure("no_ignore_case");
%colors = (
'DEBUG' => 'yellow',
'INFO' => 'green',
'WARN' => 'cyan',
@cedricvidal
cedricvidal / .gitignore
Created November 24, 2012 09:25 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################