This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <vector> | |
template <typename T> | |
std::vector<T> read_binary(std::string fname, size_t n, size_t m, bool reverse = false, bool verbose = false) | |
{ | |
union u | |
{ | |
char c[sizeof(T)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'option_blogname', 'tr_option_blogname' ); | |
function tr_option_blogname( $blogname ) { | |
return __($blogname, 'my-theme-child'); | |
} | |
add_filter( 'option_blogdescription', 'tr_option_blogdescription' ); | |
function tr_option_blogdescription( $blogdescription ) { | |
return __($blogdescription, 'my-theme-child'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iterator> | |
#include <algorithm> | |
template <typename Iter, typename T> | |
size_t find_index(Iter begin, Iter end, T x0) | |
{ | |
return std::distance(begin, std::find_if(begin, end, [x0](double x){return x >= x0;})); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename Iter> | |
Iter cyclic(Iter begin, Iter end, int i) | |
{ | |
auto n = std::distance(begin, end); | |
while (i < 0) i += n; | |
return begin + (i % n); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ps=polyconic_coast.ps | |
w=2.0944c | |
proj=Poly/${w} | |
lon0=-180 | |
lon1=`expr ${lon0} + 30` | |
reg=${lon0}/${lon1}/-90/90 | |
gmt psbasemap -R${reg} -J${proj} -K -Bg10/g10 > ${ps} | |
gmt pscoast -R${reg} -J${proj} -O -K -W -B >> ${ps} | |
while [ ${lon0} -lt 120 ]; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env octave -qf | |
function y = f(x) | |
y = coth(0.5*x) - 0.5*x; | |
endfunction | |
format long | |
fsolve("f", 1.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env octave -qf | |
function y = f(x) | |
# the maximum of kci = sqrt((mu/2 - tanh mu/2)(mu/2 - cot mu/2)) is found by | |
# finding the zero of the derivative of the inside of sqrt. | |
y = x - (tanh(0.5*x) + coth(0.5*x)) - 0.5 * x * (1/(cosh(0.5*x))^2 - 1/(sinh(0.5*x))^2); | |
endfunction | |
format long | |
fsolve("f", 3.2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
incrh () { | |
# Arguments | |
# 1: yyyymmddhh | |
# 2: dh | |
yyyymmddhh=$1 | |
dh=$2 | |
hour2sec=3600 | |
t0=`date -jf "%Y%m%d%H%M%S" ${yyyymmddhh}0000 "+%s"` | |
dh=`expr $dh \* $hour2sec` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
# http://unix.stackexchange.com/questions/48672/remove-comma-between-the-quotes-only-in-a-comma-delimited-file | |
BEGIN { | |
FS = "\"" | |
OFS = "" | |
} | |
{ | |
for (i = 2; i <= NF; i += 2) { | |
gsub(",", "", $i) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# xinput set-prop device property value [...] | |
# device: 10 indentified with `xinput list` | |
# property: 272 or Evdev Scrolling Distance indentified with `xinput list-props device` | |
# value: -1 1 1 changed from 1 1 1 | |
$ xinput set-prop 10 272 -1 1 1 |