Skip to content

Instantly share code, notes, and snippets.

View retrography's full-sized avatar

Mahmood S. Zargar retrography

  • VU Amsterdam
  • Amsterdam, Netherlands
  • X @mszargar
View GitHub Profile
@retrography
retrography / neo4R_example.R
Last active August 29, 2015 14:00 — forked from mhermans/neo4R_example.R
Fetches graph data directly from Neo4j REST API into R. Useful for R igraph users.
# Requirements
#sudo apt-get install libcurl4-gnutls-dev # for RCurl on linux
#install.packages('RCurl')
#install.packages('RJSONIO')
library('RCurl')
library('RJSONIO')
query <- function(querystring) {
h = basicTextGatherer()
@retrography
retrography / textreader.rb
Created May 8, 2014 18:13
This is the shortest way of opening a text file in Ruby and transferring its whole content to a single string variable.
#!/usr/bin/env ruby
s = IO.read(ARGV.first)
puts s
@retrography
retrography / audio2alac.markdown
Last active April 15, 2017 13:33
A simple shell script that converts audio files into Apple Lossless (ALAC) format. It can be used to create an Automator service on MacOSX. Requires brew, ffmpeg, coreutils, AtomicParsley and rmtrash.

Instructions

  • Install requirements using brew

Requires ffmpeg, coreutils, AtomicParsley and rmtrash If you don't have brew:

xcode-select --install
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Then install the required packages:

@retrography
retrography / TextReader.scala
Created June 21, 2014 17:07
The shortest way to read an entire text file into a string using Scala
object TextReader{
def main(args: Array[String]) {
val file = scala.io.Source.fromFile(args(0), "utf-8")
val content = file.mkString
file.close
print(content)
}
}
@retrography
retrography / personlinker.cypher
Created June 21, 2014 17:18
Basic Neo4j Cypher query to link all the individuals in the graph database using the same email address
MATCH (a:Person), (b:Person {email:a.email})
WHERE HAS(a.email) AND HAS(b.email)
AND a.email IS NOT NULL AND b.email IS NOT NULL
AND a<>b
CREATE UNIQUE (a)-[i:IS]-(b);
@retrography
retrography / autoneg
Created September 16, 2014 06:50
An extension to 'negfix8' to automate negative scanning even further. Including dust removal (64-bit RGBI images), color inversion, auto-crop, unsharp masking, etc...
#!/bin/sh
#convert raw-rgbi-i.tif -negate -lat 10x10+2% -negate alpha.png
echo "Extracting RGB channels to rgb_$1..."
tiffcrop -N 1 $1 rgb_$1 2>/dev/null
echo "Extracting RGB channels to i_$1..."
tiffcrop -N 3 $1 i_$1 2>/dev/null
@retrography
retrography / audio_concat
Created September 24, 2014 02:47
Lossless concatenation of audio files with ffmpeg
#!/bin/bash
ffmpeg -f concat -i <(for f in /Users/mah/Desktop/*.m4a; do echo "file '$f'"; done) -c copy /Users/mah/Desktop/interview.m4a
@retrography
retrography / xls2csv.rb
Last active August 29, 2015 14:08
xls2csv batch extractor
#!/usr/bin/env ruby
cdir=ARGV[0]
cdir='.' if cdir.nil?
flist=Dir.glob(cdir.chomp('/')+'/*.xls')
flist.each do |x|
wlist=`xls2csv -x #{x} -q -W | tail -n +4 | head -n -1`.split( /\r?\n/ )
@retrography
retrography / etl.xml
Last active August 29, 2015 14:08
A Scriptella configuration file for exporting data directly from Neo4j into a MySQL database
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>Scriptella ETL File Template.</description>
<!-- Connections with batch-loading configuration -->
<connection id="graph" driver="org.neo4j.jdbc.Driver"
url="jdbc:neo4j://graphserver:7474">
statement.fetchSize = 1000
</connection>
@retrography
retrography / user.sh
Created January 29, 2015 18:05
Adding or removing a user from a group on MaxOS
sudo dseditgroup -o edit -a user1 -t user group1
sudo dseditgroup -o edit -d user1 -t user group1