Skip to content

Instantly share code, notes, and snippets.

View ernestohs's full-sized avatar
🐙
coding in progress

/dev/10x ernestohs

🐙
coding in progress
View GitHub Profile
@ernestohs
ernestohs / housekeeping.sh
Created February 8, 2016 17:57
House Keeping for Ubuntu
#!/bin/bash
apt-get update #resync package index
apt-get upgrade #newest versions of all packages, update must be run first
apt-get autoremove #removes depenancies no longer needed
# Removes .deb files that are no logner used
apt-get autoclean # only removes files that cannot be downloaded anymore (obsolete)
apt-get dist-upgrade #updates dependancies
@ernestohs
ernestohs / docker-dump-image.sh
Created November 19, 2015 19:01
Build a docker file from an image
#!/bin/bash
docker history --no-trunc "$1" | \
sed -n -e 's,.*/bin/sh -c #(nop) \(MAINTAINER .*[^ ]\) *0 B,\1,p' | \
head -1
docker inspect --format='{{range $e := .Config.Env}}
ENV {{$e}}
{{end}}{{range $e,$v := .Config.ExposedPorts}}
EXPOSE {{$e}}
{{end}}{{range $e,$v := .Config.Volumes}}
VOLUME {{$e}}
function debug_containers()
{
var parse_container = function (container, option){
var result = [];
try {
result = container.container('getData', option);
if (!result.join) { result = []; }
} catch (e) { console.warn('There is no info for ' + option); }
@ernestohs
ernestohs / gist:3a8b0f881e1b8ef5d302
Created September 17, 2015 22:14
Beyond Compare + TortoiseSVN
Diff Viewer:
"C:\Program Files (x86)\Beyond Compare 4\BComp.exe" %base %mine /title1=%bname /title2=%yname /leftreadonly
Merge Tool:
"C:\Program Files (x86)\Beyond Compare 4\BComp.exe" %mine %theirs %base %merged /title1=%yname /title2=%tname /title3=%bname /title4=%mname
@ernestohs
ernestohs / nano-http-server.ps1
Created September 9, 2015 18:15
Nano Web Server, Less than 50 lines of code
$routes = @{
"/about" = { return '<html><body>Quick and dirty HTTP Server</body></html>' };
"/status" = { return '<html><body>Server is up and running!</body></html>' };
"/home" = { return Get-Content -Path "index.html" | Out-String };
# Add new paths here
}
$url = 'http://localhost:8080/'
$listener = New-Object System.Net.HttpListener
$listener.Prefixes.Add($url)
@ernestohs
ernestohs / get-heroku.sh
Created August 17, 2015 17:31
Heroku@Ubuntu
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
function end-profiling {
VsPerfCmd.exe /GlobalOff
VsPerfCmd /Shutdown
VsPerfClrEnv /off
write-host "Profilers detached."
}
function begin-profiling ( [string] $session, [string] $report_path ) {
if (-not (test-path $report_path )) {
mkdir "$report_path"| out-null
}
$env:_NT_SYMBOL_PATH = "srv*C:\mssymbols*http://msdl.microsoft.com/downloads/symbols"
$profilerPath = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools"
if (-not ($env:Path.Contains($profilerPath))) {
$env:Path += (";" + $profilerPath);
function get-assemblies([string] $path, [regex] $expr) {
# if you havin' regex problems I feel bad for you son
# I got \d+ problems and matching text ain't one.
dir $path | where { $expr.IsMatch($_.Name) } | select Name
}
function instrument-binaries ([string] $basePath, $assemblies) {
$profilerPath = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools"
if (-not ($env:Path.Contains($profilerPath))) {
4FBC721E39170F9CC37E75DCFDB870C5FD5448A51A463F6209AF029EE687D718B881A9D48BD8