Skip to content

Instantly share code, notes, and snippets.

View pung96's full-sized avatar

Beomsu Chang pung96

  • University of Jyvaskyla
View GitHub Profile
@pung96
pung96 / multi_vector.h
Last active August 29, 2015 14:19
multi_vector
template <typename T, int dim> class multi_vector_tool;
template <typename T, int dim> using multi_vector = typename multi_vector_tool<T,dim>::type;
template <typename T, int dim>
struct multi_vector_tool{
typedef std::vector<typename multi_vector_tool<T,(dim-1)>::type> type;
static void resize( multi_vector<T,dim> & vec, std::array<int,dim> index, T v = T{} ){
vec.resize( index[0] );
std::array<int,dim-1> index2;
std::copy(index.begin()+1,index.end(), index2.begin() );
for( auto & a : vec )
@pung96
pung96 / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
setw -g automatic-rename off
setw -g utf8 on
setw -g mode-keys vi
setw -g xterm-keys on
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
@pung96
pung96 / bench.sh
Last active August 29, 2015 14:08
#!/bin/bash
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo )
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo )
tram=$( free -m | awk 'NR==2 {print $2}' )
swap=$( free -m | awk 'NR==4 {print $2}' )
up=$(uptime|awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }')
echo "CPU model : $cname"
0,1 : beam jets
2,3 : outgoring jets
0+1 : sum of beam jets
2+3 : sum of out going jets
0 : (px,py,pz,E,m) = ( -4.3513, 2.9361, 2419.6551, 2420.0409, 42.8886 ) (p,Eta,Phi) = ( 2419.6608, 6.8264, 2.5480 )
1 : (px,py,pz,E,m) = ( 17.2348, -9.0879,-2470.5143, 2495.9275, 354.7303 ) (p,Eta,Phi) = ( 2470.5911,-5.5358,-0.4852 )
2 : (px,py,pz,E,m) = ( 3.3211, -8.7107, -10.5389, 14.9457, 5.0397 ) (p,Eta,Phi) = ( 14.0704,-0.9707,-1.2065 )
3 : (px,py,pz,E,m) = ( -16.2046, 14.8625, 61.3982, 89.0859, 60.6883 ) (p,Eta,Phi) = ( 65.2167, 1.7506, 2.3994 )
@pung96
pung96 / .tmux.conf
Created February 22, 2014 11:18
pung96's tmux configuration
#==== Prefix Key : Make it use C-a, similar to screen ====#
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
bind a send-prefix
#==== Toggle Sync Pane -> Send command to all panes ====#
bind-key s set-window-option synchronize-panes
on open theseFiles
set listSize to count of theseFiles
set counter to 1
set results to ""
tell application id "com.Growl.GrowlHelperApp"
set the allNotificationsList to {"Uploaded"}
set the enabledNotificationsList to {"Uploaded"}
register as application "PicasaUploader" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"
notify with name "Uploaded" title "Start Picasa Upload" description "( " & listSize & " ) File(s)" application name "PicasaUploader"
repeat with thisFile in theseFiles
@pung96
pung96 / gist:2549001
Created April 29, 2012 09:30
Youtube2Mp3
javascript:function cMp3(){
var cUrl=location.href;
var yPar=(cUrl.match(/v=([a-zA-Z0-9_\-]*)/))[1];
var nUrl="http://dirpy.com/studio/"+yPar
+"? album=youtube&srcfmt=18&comment=youtube,"
+encodeURIComponent("http://www.youtube.com/watch?v="+yPar);
window.open(nUrl,"_blank");
};
cMp3();
#!/usr/bin/perl
#===============================================================================
#
# FILE: intime.pl
#
# USAGE: ./intime.pl
#
# DESCRIPTION:
#
# OPTIONS: ---
#!/usr/bin/perl
#===============================================================================
#
# FILE: intime.pl
#
# USAGE: ./intime.pl
#
# DESCRIPTION:
#
# OPTIONS: ---