Skip to content

Instantly share code, notes, and snippets.

View HeLiBloks's full-sized avatar

Henrik Lindgren HeLiBloks

  • Stockholm
View GitHub Profile
@HeLiBloks
HeLiBloks / vimDep.sh
Last active May 7, 2016 20:05
my Vim Depedencies
#for dbext:
apt-get install unixodbc
perl -MCPAN -e 'install Bundle::DBI' -e 'install DBD::ODBC'
#for vim-sql-workbench
#sqlite
wget https://bitbucket.org/xerial/sqlite-jdbc/downloads/sqlite-jdbc-3.8.11.2.jar
#mysql
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.38.tar.gz
@HeLiBloks
HeLiBloks / squid_commands.sh
Last active May 4, 2016 09:38
Useful squid commands
find . | xargs head -n1 | strings | grep :// > squid-urls.txt #list of urls in squid cache
#purge pattern from cache
for x in `cat squid-urls.txt | grep foo`; do
squidclient -m PURGE $x ;
done
#format the dates
perl -p -e 's/^([0-9\.]*)/"[".localtime($1)."]"/e' *.log
@HeLiBloks
HeLiBloks / xmodmap
Created April 28, 2016 19:10
remap esc and capslock
#this is for a file that should get sourced on startup
#call it with xmodmap ~/.Xmodmap
cat > ~/.Xmodmap << EOF
remove Lock = Caps_Lock
add Lock = Escape
keysym Caps_Lock = Escape
keysym Escape = Caps_Lock
@HeLiBloks
HeLiBloks / vimtags.sh
Created April 20, 2016 15:33
generate ctags file for use in VimL script
#!/bin/bash
#vim:set et sw=4 ts=4 foldenable foldmethod=marker:
tagsSourcedVimFiles(){
# create tagfile containing sourced scriptfiles
[ -f /tmp/tagtemp ] && rm -f /tmp/tagtemp
nvim -c"redir => message|silent scriptnames|redir END" \
-c"silent put=message" \
-c"w /tmp/tagtemp|q!" &&\
cut -f2 -d':' /tmp/tagtemp\
@HeLiBloks
HeLiBloks / curl.sh
Last active April 15, 2016 14:04
curl scripts
#!/bin/sh
#show size of remote file, should fetch only header
curl 'http://www.ruhbarbdownloads.remote'\
--silent -H 'Accept-Encoding: gzip,deflate'\
--write-out 'size_download=%{size_download}\n'\
--output /dev/null
#show header
curl -sI 'http://www.ruhbarbdownloads.remote' #| awk '/Content-Length/ { print $2 }'
@HeLiBloks
HeLiBloks / date.sh
Created April 5, 2016 17:22
convert dates in nix
#nix date conversion
# time2unixStamp
date -d "2016/03/01 01:00:00" "+%s"
#readline
while read line ; do echo $line\;$(date -d "$t" "+%s") ; done < $1
#unixTime2human
date -d @1458636426
awk '{ print strftime("%c", $0); }' $1
@HeLiBloks
HeLiBloks / Regexp.sh
Last active April 4, 2016 21:51
Regexp for each case
# Dates YYYY-MM-DD HH:MM:SS
grep -oP '[1-2][90][0-9]{2,2}([-/ ])[0-2][0-9]\1[0-2][0-9] [0-2][0-9]([:])[0-6][0-9]\2[0-6][0-9]'
#
perl -pe 's/[^[:ascii:]]//g'
@HeLiBloks
HeLiBloks / htmlTable.sh
Last active April 4, 2016 13:03
html table from csv file with sed
#!/bin/sh
sed -re '
s/^.*$/<tr>\n<td>&<\/td>\n<\/tr>/g
s/[,]/<\/td>\n<td>/g
1i <table style="width:100%">
$a\<\/table>' "$1"
@HeLiBloks
HeLiBloks / .vimrc.smal
Last active April 2, 2016 09:38
.vimrc
" Modeline and Notes"{
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker="{,"} foldlevel=0 foldmethod=marker filetype=vim noswapfile spell:
"}
let g:python_host_prog='/usr/bin/python2.7'
let g:python3_host_prog = '/usr/bin/python3'
set nocompatible " be iMproved, required
filetype off " required
@HeLiBloks
HeLiBloks / ctags
Last active March 31, 2016 19:13
ctags lang def for xml
--langdef=XML
--langmap=XML:.xml .xmla .cube .dim .sln .database .dwproj .dwproj.user .partitions .ds .dsv
--regex-XML=/id="([a-zA-Z0-9_]+)"/\1/d,definition/
--regex-sh=/^.*[ \t]*([A-Za-z][A-Za-z0-9_]*)=[".]*/\1/k,tasks/
--languages=+sh