Skip to content

Instantly share code, notes, and snippets.

@meresmclr
meresmclr / CMakeLists_hdf5.txt
Created September 5, 2016 02:16
basic HDF5 Cmake
cmake_minimum_required (VERSION 3.1) #yes, CMake 3.1 is required
project(myproj C)
# https://gist.github.com/scienceopen/9f88bbe4841ea67aa692f7395bb38bfe
add_executable(myprog ../myprog.c)
find_package(HDF5 REQUIRED)
include_directories(${HDF5_INCLUDE_DIR})
target_link_libraries(myprog ${HDF5_C_LIBRARIES})
@meresmclr
meresmclr / expanduser.m
Created September 2, 2016 18:49
Like os.path.expanduser() but for Matlab/Octave
function expanded = expanduser(p)
%%
% Examples:
%
% isunix==1 (linux & cygwin) example:
% expanduser('~/Downloads/foo')
% ans = /home/joespc/Downloads/foo
%
% ispc==1 example (Windows)
% expanduser('~/Downloads/foo')
@meresmclr
meresmclr / wpa_cli-success.txt
Last active September 2, 2016 18:29
Successful Wifi connection output from wpa_cli
$ wpa_cli -i wlan0 status
ssid=BU (802.1x)
id=2
mode=station
pairwise_cipher=CCMP
group_cipher=TKIP
key_mgmt=WPA2/IEEE 802.1X/EAP
wpa_state=COMPLETED
ip_address=155.41.65.23
@meresmclr
meresmclr / wpa_supplicant.conf
Created September 2, 2016 18:18
addition for Boston University Wifi network
network={
ssid="BU (802.1x)"
key_mgmt=WPA-EAP
pairwise=CCMP TKIP
eap=TTLS PEAP MSCHAPV2
identity="Your BU login"
password="your Kerberos Password: be aware others can read this file!"
phase2="auth=MSCHAPV2"
}
#!/bin/bash
# reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=23440
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm" "$days" "$hours" "$mins" `
import ephem
import datetime
now = datetime.datetime.now() #get current time
Boston=ephem.Observer()
Boston.pressure = 1010 # millibar
Boston.temp = 25 # deg. Celcius
Boston.horizon = 0
Boston.lat='42.3462'
@meresmclr
meresmclr / matlab_lossless_video.m
Created September 2, 2016 05:16
make a lossless motion jpeg 2000 video with matlab
v = VideoWriter('test.mj2','Motion JPEG 2000');
v.LosslessCompression = true; v.FrameRate=5;
open(v)
f=figure; title('line'), ylabel('amplitude'),xlabel('index')
pause(0.2) %let plot wake up
for i=1:.05:3;
line(0:.01:1,(0:.01:1).^i)
im = getframe(f);
writeVideo(v,im)
end
@meresmclr
meresmclr / pyramid2d.m
Created September 2, 2016 05:12
makes 2-D pyramid phantom
do:
N = 256;
MinVal = 0;
MaxVal = 2^16 -1;
data = nan(N);
temp = uint16(MinVal:round((MaxVal-MinVal)/(N/2)):MaxVal);
for i = 1:N/2
data(i,i:end-i+1) = temp(i);
data(i:end-i+1,i) = temp(i);
@meresmclr
meresmclr / matlab_animation_example.m
Last active September 2, 2016 05:10
example animated movie in Matlab or Octave
%% create data, 25 frames of 512x512 pixels
data = rand(512,512,25);
%% create blank image
img = imagesc(rand(512));
ht = title(''); % to show frame number
%% for loop to play "movie"
for i = 1:25
set(img,'cdata',data(:,:,i)) % update latest frame
#!/bin/sh
#
# finds N biggest directories.
# Alternative is "ncdu" a graphical biggest file program
\du -hd1 $1 | sort -h | head -n 8