Skip to content

Instantly share code, notes, and snippets.

Avatar

Amir M. Saeid amir

View GitHub Profile
@amir
amir / gorilla.sh
Last active May 15, 2018
Bash script for importing Gorilla passwords into pass
View gorilla.sh
#!/usr/bin/env bash
insert () {
echo -e "$2" | pass insert --multiline -f "${1}" > /dev/null
}
sanitize () {
local res=$(echo "$1" | tr -d \'\"\!\(\))
echo "$res"
}
View MyCollection.hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module MyCollections where
import Java
View gist:970386446f9f68a2b780
### Keybase proof
I hereby claim:
* I am amir on github.
* I am gluegadget (https://keybase.io/gluegadget) on keybase.
* I have a public key whose fingerprint is F3EF 9704 6BE4 440F 70D4 D01B B7D6 616C 564F 3388
To claim this, I am signing this object:
View wikifil.pl
#!/usr/bin/perl
use open qw(:std :utf8);
# Program to filter Wikipedia XML dumps to "clean" text consisting only of lowercase
# letters (a-z, converted from A-Z), and spaces (never consecutive).
# All other characters are converted to spaces. Only text which normally appears
1 #!/usr/bin/perl
# in the web browser is displayed. Tables are removed. Image captions are
# preserved. Links are converted to normal text. Digits are spelled out.
View gist:4031362
r2d2➜ /tmp cat foo.php && php foo.php
<?php
$value = 1;
$some_object = new stdClass;
var_dump((int)$some_object);
var_dump($value == $some_object);
</script>
==========
PHP Notice: Object of class stdClass could not be converted to int in /tmp/foo.php on line 4
int(1)
@amir
amir / gist:2960672
Created Jun 20, 2012
net.Dial alike Dial for SOCKS4a, and SOCKS5, or how to use http.Client's Transport element to proxy HTTP calls
View gist:2960672
package main
import (
"bytes"
"encoding/binary"
"io/ioutil"
"log"
"net"
"net/http"
"strconv"
View gist:147043
wirelessimagewidget = widget({ type = 'imagebox', align='right' })
wirelessimagewidget.image = image(beautiful.widget_wifi)
wirelesswidget = widget({ name = 'wireless', type = 'textbox', align = 'right' })
function wireless_status(format)
local sysfile = io.open("/sys/class/net/wlan0/operstate")
if sysfile == nil then
return { '' }
end
local operstate = sysfile:read()
View gist:147040
#!/bin/bash
until [ -S ~/.awesome_ctl.0 ] ; do
sleep 1
done
while [ -S ~/.awesome_ctl.0 ] ; do
echo gmailwidget.text = `wget -qO- --http-user=username --http-password=password https://mail.google.com/mail/feed/atom | grep fullcount | sed 's/<fullcount>\(.*\)<\/fullcount>/\1/'` | awesome-client
sleep 300
done
View gist:49100
set nocompatible
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
set backspace=indent,eol,start
set t_Co=256
set number
set autoindent
set smartindent
View gist:24805
#!/bin/bash
if [ $# -ne 1 ]; then
battery_id='BAT0'
else
battery_id=$1
fi
battery_max=`cat /proc/acpi/battery/$battery_id/info | head -3 | tail -1 | awk '{print $4}'`
if [ "$(cat /proc/acpi/battery/$battery_id/state | grep -o discharging)" == "discharging" ]; then
prepend="-"
else