Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active April 19, 2025 08:19
The Gist to Clone All Gists
license: gpl-3.0
@amarraja
amarraja / gist:3938304
Created October 23, 2012 11:35
Replace system notepad with notepad++
REM Replaces notepad.exe with notepad++. Here for reference since I can never find it
REM Taken from here: http://blogs.itramblings.com/post/2009/02/08/How-to-replace-notepadexe-on-Windows-Server-2008.aspx
@echo off
echo Create Backup copies of the original notepad.exe
copy C:\Windows\notepad.exe C:\Windows\notepad32.exe
copy C:\Windows\System32\notepad.exe C:\Windows\System32\notepad32.exe
copy C:\Windows\SysWOW64\notepad.exe C:\Windows\SysWOW64\notepad32.exe
@jkeam
jkeam / GroovyExcelParser.groovy
Created November 16, 2012 02:57
A groovy script to parse an excel document.
import org.apache.poi.ss.usermodel.*
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.ss.util.*
import org.apache.poi.ss.usermodel.*
import java.io.*
class GroovyExcelParser {
//http://poi.apache.org/spreadsheet/quick-guide.html#Iterator
@kdabir
kdabir / hide_ant_log.groovy
Created November 19, 2012 18:10
Hiding AntBuilder output in groovy
def ant = new AntBuilder()
ant.echo("This Message should show up")
ant.project.buildListeners[0].messageOutputLevel = 0
ant.echo("This wont show up as long as level is zero")
@jtimberman
jtimberman / Rakefile
Created November 21, 2012 20:55
Rake task that bumps a cookbook's version for development, because I was already making rake tasks erstwhile.
desc "Updates the metadata for development version"
task :devversion do
Dir.chdir ENV['PWD']
md_file = File.join(ENV['PWD'], "metadata.rb")
if File.exist?(md_file)
begin
require 'chef/cookbook/metadata'
require 'versionomy'
rescue LoadError
@naholyr
naholyr / _service.md
Created December 13, 2012 09:39
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@benjchristensen
benjchristensen / FuturesB.java
Last active December 19, 2024 23:11
FuturesB.java Example of using Futures for nested calls showing how it blocks inefficiently.
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@josericardo
josericardo / PageableCollection.java
Last active September 26, 2023 06:21
Helper to iterate over pageable sources. Should reduce memory usage when querying large tables via Spring Data.
======================================
Usage:
Fetcher<Source, MyEntity> f = new Fetcher<Source, MyEntity>(source) {
@Override
public List<MyEntity> fetch(Pageable pageRequest)
{
return source.findAll(pageRequest);
}
};
@jswanner
jswanner / migrate.rake
Last active August 15, 2024 15:15
Rolls back migrations in current branch not present in specified branch.
desc 'rolls back migrations in current branch not present in other'
task :rollback_branch_migrations, [:other_branch] do |t, args|
load "#{Dir.pwd}/Rakefile"
branch_migrations = BranchMigrations.new(args.other_branch)
puts ['Rollback the following migrations', branch_migrations, 'y,n? ']
next if %w[no n NO N].include?(STDIN.gets.chomp)
Rake::Task['environment'].invoke
@matthewadams
matthewadams / rmdirs.groovy
Created May 2, 2013 13:48
Closure to remove an entire directory tree.
rmdirs = {
it = (it instanceof File) ? it : new File(it)
if (!it.exists()) return
it.eachDir(delDir)
it.eachFile { it.delete() }
it.delete()
}