Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
@linktohack
linktohack / lyxit
Last active October 20, 2015 13:57
vim/emacs edit current region in lyx
#!/bin/bash
TMPNAME=$(mktemp -t lyxit)
tee ${TMPNAME}.tex 2>/dev/null 1>/dev/null
tex2lyx ${TMPNAME}.tex 2>/dev/null 1>/dev/null
lyx ${TMPNAME}.lyx 2>/dev/null 1>/dev/null
lyx -e latex ${TMPNAME}.lyx 2>/dev/null 1>/dev/null
sed -e '1,/\begin{document}/d' -e '/\end{document}/,$d' ${TMPNAME}.tex \
| sed -e '/./,$!d' -e ':a' -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba'
@linktohack
linktohack / mod_io.f90
Created April 19, 2013 22:17
Load Text Data
subroutine load_txt_data_1d_d(d, f)
implicit none
real*8, intent(out) :: d(:) ! array of text data
character(*), intent(in) :: f ! chanel file name
open(51, file=trim(f), status='old', action='read')
read(51, *) d
close(51)
endsubroutine
@linktohack
linktohack / mod_io.f90
Created April 19, 2013 22:17
Load Binary Data
subroutine load_bin_data_1d_r(d, f)
implicit none
real*4, intent(out) :: d(:) ! array of binary data
character(*), intent(in) :: f ! chanel file name
integer*4 :: n
n = size(d)
open(51, file=trim(f), status='old', form='unformatted', &
@linktohack
linktohack / mod_fft.f90
Created April 19, 2013 22:13
Generate Frequency for FFT
function fftfreq(st, block)
implicit none
real*8, intent(in) :: st(:) ! sample time
integer, intent(in) :: block
real*8 :: fftfreq(size(st))
integer*4 :: n, i
real*8 :: t
@linktohack
linktohack / pressure.m
Created April 20, 2013 15:41
numpy Hanning Window
% Hanning Windows
window = (0:block-1)'; %' Mwhaa Sublime :))
window = 0.5*(1-cos(2*pi*window/(block-1)));
@linktohack
linktohack / pressure.m
Created April 20, 2013 15:39
Plot chanel XX of config YY
% Plot chanel 9 of config [5 6]
loglog(freqt(1:block/2), permute(x(1:block/2,9,[5 6]), [1,3,2]));
% Plot chanel [8 9 10] of config 6
loglog(freqt(1:block/2), x(1:block/2,[8 9 10],6));
@linktohack
linktohack / .vimrc
Created July 4, 2013 07:56
vim LaTeX forwad search
" LaTeXForwadSearch {{{
function! LaTeXForwadSearch()
silent! execute '!"C:\Applications\SumatraPDF\SumatraPDF.exe -reuse-instance ' \
. expand('%:p:r') . '.pdf -forward-search ' . expand('%:p') . ' ' . line('.') . '"'
" This line is reverse search for SumatraPDF
"C:\Users\Link\Dropbox\Applications\Vim\gvim.exe" --remote-silent +"%l|norm zz" "%f"
endfunction
" }}}
@linktohack
linktohack / gfortran_compiler_make.vim
Last active December 19, 2015 13:49
Vim gfortran error format
set efm=%-Ggfortran%.%#,%A%f:%l:,%A%f:%l.%c:,%A%f:%l:,%C,%C%p%*[0123456789^],%Z%trror:\ %m,,%Z%tarning:\ %m,%C%.%#,%-Gmake%.%#
@linktohack
linktohack / 6.el
Last active January 4, 2016 23:38
Regions - multiple selections
(provide 'regions)
(defvar regions nil
"Regions in buffer.")
(defun regions-maybe-push-selection ()
"Push mark and point if point is not in regions."
(let ((point (point))
exists)
(dolist (sel regions)
@linktohack
linktohack / metaview.py
Last active March 3, 2016 11:40
MITM rule for bigger screen
# Usage: mitmdump -s "modify_response_body.py mitmproxy bananas"
# (this script works best with --anticache)
from libmproxy.models import decoded
script = '''
<script type="text/javascript">
(function() {
var width = 400;
big();