Skip to content

Instantly share code, notes, and snippets.

View mdellabitta's full-sized avatar

Michael Della Bitta mdellabitta

View GitHub Profile
@mdellabitta
mdellabitta / gist:1331881
Created November 1, 2011 20:57
Using Kakadu to make JPEG2000s out of a folder of images
#!/usr/bin/env ruby
kdu_compress = ???
Dir.open(in_path).each do |in_file|
j_file = ???
success &= system(kdu_compress, "-quiet", "-i", in_file, "-o", j_file, "-jp2_space", "sRGB", "Creversible=yes", "-rate", "-,1,0.84,0.7,0.6,0.5,0.4,0.35,0.3,0.25,0.21,0.18,0.15,0.125,0.1,0.088,0.075,0.0625,0.05,0.04419,0.03716,0.03125,0.025,0.0221,0.01858,0.015625", "Clevels=6", "Stiles={1024,1024}", "Cmodes={BYPASS}", "Corder=RLCP")
end
@mdellabitta
mdellabitta / gist:1444504
Created December 7, 2011 20:31
Fedora DOS Attack?
require 'csv'
CSV.open("list_of_pids.csv", "rb").each do |csv|
pid = csv[1]
["JP2", "THUMBNAIL", "WIDE_THUMBNAIL", "REFERENCE_THUMBNAIL"].each do |ds_id|
response = `curl --silent -I "http://example.org:8080/fedora/objects/#{pid}/datastreams/#{ds_id}/content" --user "fedoraAdmin:somepassword"`
puts "#{csv[0]},#{csv[1]},#{ds_id},#{response.lines.first}"
end
end
@mdellabitta
mdellabitta / gist:1444522
Created December 7, 2011 20:35
Fedora HTTP client settings
<param name="httpClientTimeoutSecs" value="20">
<comment>Number of seconds Fedora http client will wait for a connection before timing
out.</comment>
</param>
<param name="httpClientSocketTimeoutSecs" value="120">
<comment>Number of seconds Fedora http client will wait for data coming across an
established http connection.</comment>
</param>
<param name="httpClientMaxConnectionsPerHost" value="20">
<comment>Maximum number of Fedora http client connections allowed to a given host.</comment>
@mdellabitta
mdellabitta / gist:4171654
Created November 29, 2012 20:23
Simple script for autodetecting number of displays and switching between xrandr/arandr layouts
#!/usr/bin/env ruby
output = `xrandr --query`
ids = output.lines.find_all do |line|
line =~ /\sconnected/
end
if ids.size == 1
<add>
<doc>
<field name="one">1</field>
<field name="one">3</field>
<field name="two">2</field>
<field name="two">4</field>
<field name="two">6</field>
<field name="two">8</field>
</doc>
</add>
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Mapper;
public class SolrMapper extends Mapper<LongWritable, Text, Text, Text> {
private HttpSolrServer solrServer;
private Text outKey = new Text();
@Override
@mdellabitta
mdellabitta / gist:6065621
Created July 23, 2013 19:57
Maven assembly for hadoop jar
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>some-id</id>
<configuration>
<finalName>some-name</finalName>
@mdellabitta
mdellabitta / assembly.xml
Created July 23, 2013 19:58
assembly.xml for hadoop jar... in src/main/resources
<?xml version="1.0" ?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>hadoop</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>

Keybase proof

I hereby claim:

  • I am mdellabitta on github.
  • I am mdellabitta (https://keybase.io/mdellabitta) on keybase.
  • I have a public key ASBjFMmoR7kiSy8ncYpQwNh9_0tJDm6xWvu5u9_nm9mE6go

To claim this, I am signing this object:

@mdellabitta
mdellabitta / gist:1444003
Created December 7, 2011 18:32
how do do spring jdbc transactions with jdbctemplate/transactiontemplate
public class ExodusWriter {
private JdbcTemplate jdbcTemplate;
private TransactionTemplate transactionTemplate;
public ExodusWriter(DataSource dataSource) {
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
jdbcTemplate = new JdbcTemplate(transactionManager.getDataSource());
transactionTemplate = new TransactionTemplate(transactionManager);
}