Skip to content

Instantly share code, notes, and snippets.

@tueda
tueda / jaxmanip.py
Created May 2, 2014 19:14
Manipuate JaxoDraw2 xml files.
#!/usr/bin/python
from xml.etree.ElementTree import *
from optparse import OptionParser
def get_xypoints(node):
xpoints = []
ypoints = []
for e in node.findall(".//void[@class='java.awt.Point'][@method='getField']"):
e_name = e.find("string")
@tueda
tueda / prog-versions.sh
Last active August 29, 2015 14:02
It checks versions of several programs installed on the current machine.
#!/bin/sh
found=false
for file in /etc/redhat-release /etc/SuSE-release; do
if [ -f "$file" ]; then
cat "$file" | head -1
found=:
break
fi
done
@tueda
tueda / my_system.pl
Created June 21, 2014 09:03
system command with a timeout. (Unix only)
# my_system($command, $timeout = 10) [Unix]
sub my_system($;$) {
use POSIX qw(:sys_wait_h);
my $command = $_[0];
my $timeout = $_[1] || 10;
my $pid = fork();
if (!defined($pid)) {
return -1; # failed to fork
@tueda
tueda / FORM.m
Last active October 19, 2015 12:54
A Mathematica package to execute FORM programs embedded in Mathematica code. #mma
(*
* FORM.m
*
* Executes a FORM program in Mathematica.
*
* https://gist.githubusercontent.com/tueda/e3a2cc73fbed2a8e2ae4/raw/FORM.m
*
* Example:
*
* << FORM`
@tueda
tueda / pform
Last active October 19, 2015 12:53
A preprocessor for FORM. #bin #form
#! /usr/bin/env perl
##
# @file pform
#
# pform - (pre)preprocessor of FORM
#
# Copyright (c) 2011 Takahiro Ueda
#
@tueda
tueda / ndiff
Last active August 11, 2016 17:40
A program to compare numerical values in files. #bin #python
#!/bin/sh
""":" .
exec python "$0" "$@"
"""
import argparse
import math
import os
import sys
@tueda
tueda / repo-date.sh
Last active October 19, 2015 12:53
Print the last commit date of the current repository. #bin
#! /bin/sh
# Get the last commit date from the repository.
if [ -d .git ] || [ -d ../.git ] || [ -d ../../.git ] || [ -d ../../../.git ] || [ -d ../../../../.git ] ; then
date=`git log -1 --format=%ci`
elif [ -d .svn ]; then
date=`svn info | grep '^Last Changed Date:' | sed 's/.*Last Changed Date: *\([^(]*\)(.*/\1/'`
elif [ -d CVS ]; then
date=`cvs log -N 2>/dev/null | grep '^date:' | sort | tail -n 1 | sed 's/.*date: *\([^;]*\);.*/\1/' | sed 's|/|-|g'`' +0000'
else
@tueda
tueda / math.sh
Last active October 19, 2015 12:53
A launcher for Mathematica programs. #bin #mma
#! /bin/sh
#
# @file math.sh
#
# A launcher for Mathematica programs.
#
# Example:
# math.sh variable=string-value file.m
#
set -e
@tueda
tueda / formprof.py
Last active December 14, 2020 11:29
FORM log profiler. #bin #form #python NOTE: migrating to https://github.com/tueda/formprof.
#!/bin/sh
""":" .
exec python "$0" "$@"
"""
from __future__ import print_function
import argparse
import copy
@tueda
tueda / gist:00e68c7d411990006e05
Last active March 21, 2024 12:30
Python -> CProfile -> gprof2dot -> dot
python -m cProfile -o output.pstats path/to/your/script arg1 arg2
gprof2dot.py -f pstats output.pstats | dot -Tpdf -o output.pdf