Skip to content

Instantly share code, notes, and snippets.

@yuasatakayuki
yuasatakayuki / fog_simpledb_put_get.rb
Last active August 29, 2015 14:13
Ruby Fog::AWS::SimpleDB Example
require "fog"
#Create a Fog AWS SimpleDB instance
sdb = Fog::AWS::SimpleDB.new(
:aws_access_key_id => "YOUR_ACCESS_KEY_ID",
:aws_secret_access_key => "YOUR_SECRET_ACCESS_KEY",
:region => "ap-northeast-1" #meaning "Tokyo"
)
#Create domain
@yuasatakayuki
yuasatakayuki / upload_file_to_mediawiki
Created March 7, 2015 13:56
Upload file to MediaWiki using Ruby Mechanize
#!/usr/bin/env ruby
if(ARGV.length<1)then
puts "Provide file to be uploaded."
exit
end
require "mechanize"
#check file
@yuasatakayuki
yuasatakayuki / go_xis_calculate_powerspectrum_for_intervals.sh
Created April 13, 2015 02:30
Suzaku/XIS powerspectrum calculation example (using interval-sliced event files)
# Calculates powerspectra of each interval
binTime=32
nbint=128
nintfm=20
function doProcess(){
if [ `hsStringIndex $outputFile 45` = -1 ]; then
xLabel="lab nx off"
else
@yuasatakayuki
yuasatakayuki / CMakeLists.txt
Last active August 29, 2015 14:19
CMakeLists.txt for sfitsio
#---------------------------------------------
# CMakeLists.txt for sfitsio
#---------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
SET(CMAKE_C_FLAGS_RELEASE "-Wall -O3")
SET(CMAKE_C_FLAGS_DEBUG "-g")
SET(CMAKE_BUILD_TYPE Release)
@yuasatakayuki
yuasatakayuki / CMakeLists.txt
Last active August 29, 2015 14:19
CMakeLists.txt for sllib
#---------------------------------------------
# CMakeLists.txt for sllib
#---------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
SET(CMAKE_C_FLAGS_RELEASE "-Wall -O3")
SET(CMAKE_C_FLAGS_DEBUG "-g")
SET(CMAKE_BUILD_TYPE Release)
@yuasatakayuki
yuasatakayuki / read_and_fit_histogram.rb
Last active August 29, 2015 14:23
RubyROOT example: fill histogram then fit with gaussian+pol1
require "RubyROOT"
include Root
include RootApp
inputFile="histogram_sample.data"
outputPDFFile="histogram_sample.pdf"
#create an instance of histogram
hist=TH1D.create("hist","Histogram",512,0,512)
@yuasatakayuki
yuasatakayuki / conver_fits_to_csv.rb
Created January 20, 2016 09:20
a short example of FITS Table HDU read access using RubyFits
#!/usr/bin/ruby
# This script dumps data contained in a FITS Table HDU into a CSV file using RubyFits.
# Usage:
# ruby conver_fits_to_csv.rb FITS_FILE
# Output:
# - Header: FITS_FILE_n_header_HDU_NAME
# - Data : FITS_FILE_n_data_HDU_NAME
# (n is HDU index)
@yuasatakayuki
yuasatakayuki / calculate_fermi_energy_of_white_dwarf.rb
Created January 20, 2016 10:55
Calculates Fermi energy of a white dwarf star using ruby-dimensional module
#!/usr/bin/env ruby
# Calculates the Fermi energy and temperature of a typical white dwarf star.
require "ruby-dimensional-standard"
require "ruby-dimensional-physics"
#define constants
G=Physics::Constant::GravitationalConstant
Msun=Physics::Constant::Msun
@yuasatakayuki
yuasatakayuki / use_ruby_wrapper_of_spacewire_rmap_library.md
Last active February 15, 2016 01:38
User Ruby wrapper of SpaceWire/RMAP Library

Now users can use basic SpaceWire and RMAP functionalities of the library in the Ruby scripting language. Scripting capability allows developers to quickly iterate try-and-error loops on, for example, new SpaceWire device without compiling a test program.

The SWIG wrapper is already included in the Github repository of SpaceWire RMAP Library, and existing users can pull it by executing:

#!/bin/bash
##############################################
#yum-related things
##############################################
sudo yum update
sudo yum groupinstall -y "GNOME Desktop" "Graphical Administration Tools" "Console Internet Tools" "Scientific Support" "Development Tools" "System Administration Tools"
sudo yum install -y zsh
sudo yum install -y openssl-devel readline-devel zlib-devel curl-devel expat expat-devel ImageMagick ImageMagick-devel bzip2-devel python-devel ruby-devel
sudo yum install -y dbus-python-devel.x86_64 gstreamer-python-devel.x86_64 lvm2-python-libs.x86_64 python-backports-lzma.x86_64 python-brlapi.x86_64