Skip to content

Instantly share code, notes, and snippets.

@justnom
justnom / extend.js
Created January 21, 2013 22:29 — forked from pilate/extend.js
Extending the 'google.visualization.DataTable' prototype with toCSV
// Extend DataTable functionality to include toCSV
google.visualization.DataTable.prototype.toCSV = function () {
var dt_cols = this.getNumberOfColumns();
var dt_rows = this.getNumberOfRows();
var csv_cols = [];
var csv_out;
// Iterate columns
for (var i=0; i<dt_cols; i++) {
@justnom
justnom / archive_svn_repo.bat
Last active December 18, 2015 02:59
Dump and compress a remote SVN repository. For SVN servers with version < 1.7.
:: Add in your url/paths
SET REPO_URL=svn://mysvnhost.com/repo/
SET REPO_PATH=D:\repo_backup\
SET REPO_DUMP_FILE=D:\repo_backup.dump
SET REPO_DUMP_FILE_ARCHIVE=%date:~-4,4%%date:~-7,2%%date:~0,2%dump.7z
SET REPO_PATH_NUX=file:///D:/repo_backup/
del %REPO_DUMP_FILE%
rmdir %REPO_PATH% /s/q
mkdir %REPO_PATH%
@justnom
justnom / addtorrent.py
Last active December 18, 2015 16:09
Transmission handler for sevabot. Requires: https://github.com/edavis/transmission-fluid
#!/usr/bin/env python
import sys
from transmission import Transmission, BadRequest
SETTINGS = {
'host': '127.0.0.1',
'port': 9090,
'username': 'foo', # Comment out if no authentication is needed
@justnom
justnom / post-commit.sh
Last active February 14, 2018 17:55
Jenkins post commit hook. Allows building for multiple folders and support for parameters. If you don't require any parameters for the Jenkins build then just leave an empty string in the `JOBS_PARAMETERS` array.
#!/bin/bash
REPOS="$1"
REV="$2"
urlencode () {
tab="`echo -en "\x9"`"
local i="$@"
i=${i//%/%25} ; i=${i//' '/%20} ; i=${i//$tab/%09}
i=${i//!/%21} ; i=${i//\"/%22} ; i=${i//#/%23}
@justnom
justnom / archive_svn_repo.bat
Last active December 19, 2015 07:59
Dump and archive an SVN repo. Uses `svnrdump` which needs SVN server >= 1.7.x.
@echo off
:: Add in your url/paths
SET REPO_NAME=%1
SET REPO_URL=%2
SET REPO_DUMP_FILE=%REPO_NAME%.dump
SET REPO_DUMP_FILE_ARCHIVE=%date:~-4,4%%date:~-7,2%%date:~0,2%_%REPO_NAME%.7z
svnrdump dump -q %REPO_URL% > %REPO_DUMP_FILE%
IF %ERRORLEVEL% NEQ 0 GOTO :FAIL
@justnom
justnom / bordered_window.cpp
Created August 5, 2013 15:05
Create a window in Windows that only has a border.
HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_BORDER, 0, 0, 500, 100, NULL, NULL, hInstance, NULL);
SetWindowLong(hWnd, GWL_STYLE, WS_BORDER | WS_THICKFRAME);
SetWindowPos(hWnd, 0, 0, 0, 100, 50, SWP_FRAMECHANGED);
@justnom
justnom / vs2010_build_context_menu.reg
Created August 7, 2013 15:21
Windows Registry file for building `.vcxproj` and `.sln` with `MSBuild` from the context-menu.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.10.0\shell\BuildDebug]
@="Build the project (Debug)"
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.10.0\shell\BuildDebug\command]
@="\"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe\" /t:Rebuild /p:Configuration=Debug \"%1\""
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.vcxproj.10.0\shell\BuildRelease]
@="Build the project (Release)"
@justnom
justnom / mvn-install-jar.sh
Last active December 21, 2015 12:48
Import .jar file into local maven repository.
mvn install:install-file -Dfile=awesome-thing-1.0.jar -DgroupId=com.mycompany -DartifactId=awesome-thing -Dversion=1.0 -Dpackaging=jar
@justnom
justnom / ignore_patterns_relative.py
Created August 30, 2013 16:48
Ignore function generator for `shutil.copytree` function.
def ignore_patterns_relative(*patterns):
"""Function that can be used as copytree() ignore parameter.
Patterns used can exclude with relative path names.
"""
def _ignore_patterns(path, names):
ignored_names = []
for pattern in patterns:
relative_names = [os.path.join(path, name) for name in names]
matched_names = fnmatch.filter(relative_names, pattern)
ignored_names.extend(os.path.basename(name) for name in matched_names)
@justnom
justnom / jenkins_backup.bat
Last active December 23, 2015 09:39
Backup linux based Jenkins settings to a Windows computer using PuTTY.
@echo off
:: Directory of Jenkins settings on server
SET JENKINS_DIR=/var/lib/jenkins
:: Directory to save the backup archives to
SET ARCHIVE_DIR=D:\Backups\Jenkins
:: PuTTY session to use for connecting to the Jenkins machine
SET PUTTY_SESSION=my_session
for /f %%i in ('plink -batch %PUTTY_SESSION% "echo $(date +%%F)"') do set DATE=%%i