Skip to content

Instantly share code, notes, and snippets.

#!/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.
@amir
amir / gorilla.sh
Last active May 15, 2018 14:55
Bash script for importing Gorilla passwords into pass
#!/usr/bin/env bash
insert () {
echo -e "$2" | pass insert --multiline -f "${1}" > /dev/null
}
sanitize () {
local res=$(echo "$1" | tr -d \'\"\!\(\))
echo "$res"
}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module MyCollections where
import Java
@amir
amir / gist:4031362
Created November 7, 2012 12:34
Stay Classy!
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 June 20, 2012 16:04
net.Dial alike Dial for SOCKS4a, and SOCKS5, or how to use http.Client's Transport element to proxy HTTP calls
package main
import (
"bytes"
"encoding/binary"
"io/ioutil"
"log"
"net"
"net/http"
"strconv"
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()
#!/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
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
#!/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
@amir
amir / gist:970386446f9f68a2b780
Created September 23, 2014 08:40
keybase.md
### 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: