Skip to content

Instantly share code, notes, and snippets.

@yuasatakayuki
yuasatakayuki / makeHistogram.C
Created November 7, 2014 17:02
create ROOT histogram from a text file containing entries
void makeHistogram(std::string fileName){
using namespace std;
ifstream ifs(fileName.c_str());
int pi;
TCanvas* c=new TCanvas("c","c",600,600);
TH1D* hist=new TH1D("hist",fileName.c_str(),2048,0,2048);
while(ifs.is_open() && !ifs.eof()){
ifs >> pi;
hist->Fill(pi);
}
@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 / install_heasoft.sh
Last active September 3, 2020 18:49
Heasoft download, build, and install script
#!/bin/bash
cat << EOF
#============================================
# Heasoft download, build, and install script
#
# For the latest version of this script, visit the gist:
# https://gist.github.com/yuasatakayuki/8176d73f7e716f95587b
#
# This script uses the Heasoft mirror hosted at the JAXA/ISAS.
@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_mcp3208.c
Created June 5, 2015 09:05
AD conversion using MCP3208 on Raspberry Pi convers
/*
* Before running this program, execute the following initialization command:
* > gpio load spi
*
* Expected result:
* > pi@raspberrypi:~$ ./read_mcp3208
*
* wiringPiSPISetup status = 3
* wiringPiSPIDataRW status = 3
* data[0]=00
@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)