Skip to content

Instantly share code, notes, and snippets.

View juandesant's full-sized avatar

Juande Santander-Vela juandesant

View GitHub Profile
@juandesant
juandesant / Sesame.py
Last active December 14, 2015 23:09
Get RA, Dec from an object name using the CDS Sesame web service in Python.
import urllib
# source is a variable containing a source name, such as M31, Alpha Centauri, Sag A*, etc
source = "Sag A*"
# This is the string with the URL to query the Sesame service,
# using a 'name' parameter.
# sesameQueryUrl = 'http://cdsws.u-strasbg.fr/axis/services/Sesame?' +\
# 'method=sesame&resultType=p&all=true&service=NSVA' +\
# '&name=%(name)s'
# use the updated CDS REST endpoint
sesameQueryUrl = 'http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-op/NSV?%(name)s'
@juandesant
juandesant / Module Layout Example
Created March 17, 2013 19:37
Possible outline of a module, to allow easier access to classes and methods.
# module layout:
# + mymodule
# |
# +---__init__.py
# |
# +---class1.py
# |
# +---class2.py
# |
# +---otherclasses/
@juandesant
juandesant / sampy_sample_client.py
Created June 26, 2013 17:36
This gist shows how to use sampy to interact with different VO applications. It assumes you have sampy installed.
#!/usr/bin/env python
from sampy import *
import time
from pprint import pprint
# Setup hub by calling "start_samp_hub.py", it would contain:
# myhub = SAMPHubServer()
# myhub.start(True) # The True makes the script standalone; it should be called with
# alternatively, sampy (/usr/local/bin/sampy, for instance) can be called:
import subprocess
@juandesant
juandesant / Download proper KML file.scpt
Last active December 20, 2015 16:18
Drag-and-drop script to download standalone KML files that do not depend of a network connection, and that can be used with things like online converters, or iOS apps. See article describing the script (in Spanish) here: http://www.entremaqueros.com/bitacoras/memoria/?p=2455
on downloadUrl(theUrl, fileName)
set curlCmd to "curl -s -L -o " & fileName & " '" & theUrl & "' "
--display dialog curlCmd
do shell script curlCmd
end downloadUrl
on run {input, parameters}
set theUrls to {}
repeat with kmlFile in input
@juandesant
juandesant / ShowCryptoProviders.java
Created August 26, 2013 13:31
Code to show available cryptography provides in Java
import java.security.Provider;
import java.security.Security;
import java.util.Arrays;
public class ShowCryptoProviders
{
public static void main(final String[] args)
{
final Provider[] providers = Security.getProviders();
for (final Provider p : providers)
@juandesant
juandesant / thanks.py
Last active December 25, 2015 04:59
Thanks to Javier Arantegui for his link on markup.se
from pprint import pprint
message = {
'title': 'Thanks to @javierarantegui’,
'description': 'Thank you message to Javier Arantegui (@javierarantegui) for his tip on markup.su'
}
pprint(message)
@juandesant
juandesant / search_functions.sh
Last active August 14, 2016 14:18
Web-based search bash macros for Mac OS X
# This script only works in Mac OS X, due to the dependency
# on the `open` command.
# It can be directly added into a .profile file, either
# by copying and pasting its content, or sourcing the
# file:
# . search_functions.sh
# Usage: google any search terms
# Result: default browser opens with a query on any
@juandesant
juandesant / .eps2jpeg.sh
Last active January 2, 2016 17:59
Bash shell function to convert EPS and PS files in JPEG using sips (Mac OS X-specific)
function eps2jpeg {
for i in $*
do
filefolder=`dirname $i`
filename=`basename $i`
tmppdf="/tmp/`uuidgen`.pdf"
ps2pdf $i $tmppdf
sips -s format jpeg $tmppdf --out "$filefolder/$filename.jpg"
rm $tmppdf
done
@juandesant
juandesant / pdfman.sh
Last active January 3, 2016 06:39
Inspired by `pman`, `sman` in Ask Different: http://apple.stackexchange.com/posts/5461/revisions
# Bash function (Mac OS X specific) for getting man pages
# in PDF visualized in Preview.app
# Tryit with `pdfman man`, `pdfman curl`, or `pdfman bash`, for instance.
pdfman() {
outname=/tmp/man-"$1".ps
man -t $1 > $outname # get PS version of man page in /tmp
if [ -s $outname ]
then {
open -a Preview $outname
}
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR