Skip to content

Instantly share code, notes, and snippets.

View tuxdna's full-sized avatar

Saleem Ansari tuxdna

View GitHub Profile
@tuxdna
tuxdna / make_rpms.rb
Created February 22, 2012 14:49
Build RPM for GEM packages
#!/usr/bin/ruby
# Author: Saleem Ansari <tuxdna@gmail.com>
# License: GPLv2
# Requirements:
# # yum install rubygem-gem2rpm
# # yum install ruby rubygems
# # yum install rpmdevtools
#
@tuxdna
tuxdna / tracwiki.rb
Created March 1, 2012 13:10
Convert a spreadsheet contents into Trac Wiki format
#!/usr/bin/ruby
# Convert a spreadsheet contents into Trac Wiki format
# How to use?
# sudo gem install spreadsheet
# ruby tracwiki.rb /path/to/spreadsheet.xls "sheet-name"
#
require 'rubygems'
require 'spreadsheet'
xlsfile = ARGV[0] if ARGV.length > 0
@tuxdna
tuxdna / koji-build.txt
Created March 1, 2012 13:12
Rails 3.1.0 GEM to RPM packaging - list of koji tasks
$ for srpm in *.src.rpm; do koji build --scratch --nowait dist-6E-epel $srpm; done
Uploading srpm: rubygem-actionmailer-3.1.0-1.fc16.src.rpm
[====================================] 100% 00:00:02 30.30 KiB 14.12 KiB/sec
Created task: 3827551
Task info: http://koji.fedoraproject.org/koji/taskinfo?taskID=3827551
Uploading srpm: rubygem-actionpack-3.1.0-1.fc16.src.rpm
[====================================] 100% 00:00:03 352.92 KiB 105.16 KiB/sec
Created task: 3827553
Task info: http://koji.fedoraproject.org/koji/taskinfo?taskID=3827553
Uploading srpm: rubygem-activemodel-3.1.0-1.fc16.src.rpm
@tuxdna
tuxdna / duplicate_files.rb
Last active October 1, 2015 12:37
Finds all the duplicate files form a directory ( for Ruby 1.9 )
#!/usr/bin/ruby
## This file finds all the duplicate files form a directory given
## at the command line.
## Released under the GPLv2
## Copyright (C) tuxdna(at)gmail(dot)com
require 'digest/md5'
require 'fileutils'
@tuxdna
tuxdna / mem-usage.rb
Created December 5, 2012 13:33
Script find usage of shared libraries of a running process
#!/usr/bin/env ruby
# filename="/proc/5952/maps"
def usage
puts "USAGE: #{$0} /proc/<pid>/maps"
exit
end
filename=ARGV[0]
@tuxdna
tuxdna / ParallelProcess.java
Created December 19, 2012 13:33
ParallelProcess to simulate Producer-Consumer problem in Java
import java.util.Random;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
class Producer implements Runnable {
private static int count = 0;
private Random rg = new Random();
private BlockingQueue<Object> queue = null;
public Producer(BlockingQueue<Object> queue) {
@tuxdna
tuxdna / insert-mysql.rb
Created February 4, 2013 12:04
A Ruby script to add binary documents into a MySQL database
#!/usr/bin/ruby
# File name: insert-mysql.rb
# Usage:
# $ ruby insert-mysql.rb /path/to/file.pdf "description of file"
require 'mysql'
require 'mime/types'
if ARGV.length < 2 then
@tuxdna
tuxdna / schema.xml
Last active February 10, 2023 11:03
Apache Solr sample schema configuration
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@tuxdna
tuxdna / solrconfig.xml
Created February 4, 2013 12:36
Solr configuration with Tika and content parsers
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@tuxdna
tuxdna / db-data-config.xml
Last active December 12, 2015 03:28
Data Source configuration for Data Import
<dataConfig>
<dataSource name="binary_files_db"
convertType="false"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/binary_files"
user="binary_user" password="binary_password"
/>
<dataSource name="fieldReader"
type="FieldStreamDataSource" />