Skip to content

Instantly share code, notes, and snippets.

View bijanebrahimi's full-sized avatar

bijan bijanebrahimi

View GitHub Profile
@bijanebrahimi
bijanebrahimi / geoformatter.sh
Created September 10, 2014 16:40
Geolocation meta data convertor (degree to decimal)
#!/bin/bash
# Geolocation meta data convertor (degree to decimal)
# Authur: Bijan Ebrahimi
# License: GPL v3.0 or any later
if [ ! "$#" == "1" ]; then
echo "Manual: `basename $0` JPG_FILE"
exit 1
fi
#!/bin/bash
TMP_FILE="/tmp/election"
wget -q http://election.farsnews.com/electioninfo.js -O $TMP_FILE
TOTAL=$(cat $TMP_FILE | grep -o "lastTotal = [0-9]\+" | sed "s/lastTotal = //" | sed "s/;//")
COUNTED=$(cat $TMP_FILE | grep -o "lastCounted = [0-9]\+" | sed "s/lastCounted = //" | sed "s/;//")
FAILED=$(cat $TMP_FILE | grep -o "lastFailed = [0-9]\+" | sed "s/lastFailed = //" | sed "s/;//")
UPDATE=$( cat $TMP_FILE | grep "categoryarray" | grep -o "[0-9:]\{5\}']" | sed "s/']//")
#!/bin/bash
TMP_FILE="/tmp/election"
wget -qO- http://election.farsnews.com/electioninfo.js | sed 's/var //' | sed 's/ = /=/' | sed "s/\[/\(/" | sed "s/\]/\)/" > $TMP_FILE
source "$TMP_FILE"
echo "last Update: "${categoryarray[${#categoryarray[@]}-1]}
echo "$lastTotal ($lastCounted, $lastFailed)"
echo "%"$(echo "scale = 4; ($lastRohani / $lastTotal) * 100" | bc 2>/dev/null)" Rohani with $lastRohani votes"
echo "%"$(echo "scale = 4; ($lastQalibaf / $lastTotal) * 100" | bc 2>/dev/null)" Qalibaf with $lastQalibaf votes"
#!/bin/bash
for i in `seq 1 42`; do
echo "retreiving page $i"
page_content=$(wget -q -O - "$@" http://iconmonstr.com/page/$i/)
echo ${page_content/$'\n'/} | grep -o "<svg [^>]*> <path [^>]*>" | while read svg; do
file_name=$(echo $svg | grep -o "id=\"[^\"]*\"" | sed 's/id="//' | sed 's/"//')
echo -en " ${file_name}.svg\t"
cat > ${file_name}.svg << EOF
<?xml version="1.0" encoding="utf-8"?>
@bijanebrahimi
bijanebrahimi / certcheck
Created August 9, 2013 21:09
Check certification fingerprints using openssl in bash
#!/bin/sh
#
# usage: certcheck hostname [port]
#
REMHOST=$1
REMPORT=${2:-443}
echo |\
openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |\
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -sha1 -noout -fingerprint
#!/bin/bash
echo "<?php"
curl -s http://www.nnvv.org/ | grep -m 2 -o "\(Password\|Username\):[a-zA-Z0-9\-]\+" | while read line; do
echo $line | sed 's/Username/\$user/' | sed 's/Password/\$pass/' | sed 's/:\(.*\)$/="\1";/'
done
echo "?>"
@bijanebrahimi
bijanebrahimi / awesome-volume.sh
Last active December 29, 2015 15:09
AwesomeWM Progressbar Volume Changer
#!/bin/bash
STEP="10"
UNIT="%"
SETVOL="/usr/bin/amixer -q sset Master"
STATE=$(amixer get Master | grep Left | egrep 'Playback.*?\[o' | egrep -o '\[o.+\]')
case "$1" in
"up")
@bijanebrahimi
bijanebrahimi / css2odtstyle.sh
Created February 11, 2016 21:55
a bash script to convert pygment css styles to odt style xml format.
#!/bin/sh
CSS=$1
read -r -d '' SNIPPET << EOM
<style:style style:name="codehilite" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="">
<loext:graphic-properties draw:fill="solid" draw:fill-color="\2" draw:fill-image-width="0in" draw:fill-image-height="0in"\/>
<style:paragraph-properties fo:margin-left="0in" fo:margin-right="0in" fo:orphans="0" fo:widows="0" fo:text-indent="0in" style:auto-text-indent="false" style:page-number="auto" fo:background-color="\2" fo:padding="0.0201in" fo:border="0.06pt solid \2" fo:keep-with-next="auto" style:snap-to-layout-grid="false" style:writing-mode="page">
<style:tab-stops\/>
<\/style:paragraph-properties>
@bijanebrahimi
bijanebrahimi / log.c
Last active September 17, 2016 19:11
simple logging in c
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include "log.h"
struct testss{
u_long level;
const char *name;
} log_names[] = {
@bijanebrahimi
bijanebrahimi / gitlab.sh
Last active February 20, 2017 14:00
Enable graphviz on gitlab markdown language
$ nano /etc/gitlab/gitlab.rb
nginx['custom_nginx_config'] = "include /var/opt/gitlab/nginx/conf/webtools.zharfpouyan.net;"
$ nano /var/opt/gitlab/nginx/conf/webtools.zharfpouyan.net
server {
listen *:80;
server_name webtools.zharfpouyan.net;
access_log /var/log/webtools.zharfpouyan.net.access.log;
error_log /var/log/webtools.zharfpouyan.net.error.log;