Skip to content

Instantly share code, notes, and snippets.

View aalemayhu's full-sized avatar
💭
If at first the idea is not absurd, then there is no hope for it - Albert

Alexander Alemayhu aalemayhu

💭
If at first the idea is not absurd, then there is no hope for it - Albert
View GitHub Profile
// http://go.googlecode.com/hg-history/release-branch.r60/doc/GoCourseDay1.pdf
package main
import (
"fmt"
"log"
"os/exec"
"strconv"
s "strings"
/**
* Draws a smiley inside the given rectangle. The mood value (0...1) is used
* to make the smiley happy or sad.
*
* @param rect Rectangle to draw the smiley into
* @param mood Happy (= 1) or sad (= 0) or anything in between
*/
-(void)drawSmileyInRect:(CGRect)rect withMood:(float)mood {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
0.0.0-{alpha, beta, chi, delta, eta, gamma, omega, omicron, sigma, theta, upsilon, xi, zeta}
def isEven(n)
n % 2 == 0
end
@aalemayhu
aalemayhu / users.php
Created March 15, 2015 20:06
utfPadding
// cisc and ccscanf
<?
require_once('db-connect-string.php');
pg_connect($db_connect_string);
$res = pg_query("SELECT ac.id + 100000 AS id, ac.name, am.full_name FROM accounts ac JOIN active_members am ON am.account = ac.id ORDER BY full_name");
header('Content-Type: text/plain; charset=utf-8');
function utfPadding($str, $len) {
@aalemayhu
aalemayhu / tmux-cheatsheet.markdown
Last active August 29, 2015 14:19 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Make it smaller for printing

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
package main
import (
"bufio"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
)
@aalemayhu
aalemayhu / commit-lang-change
Created April 29, 2015 03:17
ease committing translation changes
#!/bin/sh
# FROM http://stackoverflow.com/questions/307503/whats-the-best-way-to-check-that-environment-variables-are-set-in-unix-shellscr
[ -z "$LINGUA" ] && echo "Need to set LINGUA" && exit 1;
[ -z "$MANUAL" ] && echo "Need to set MANUAL" && exit 1;
git add -u .
commit_msg=`tempfile`
echo "($LINGUA) Use latest reviewed $MANUAL manual translation" > $commit_msg
echo >> $commit_msg
@aalemayhu
aalemayhu / xdotool
Created April 29, 2015 11:36
script my mouse
#!/bin/sh
# http://tuxradar.com/content/xdotool-script-your-mouse
xdotool mousemove 2470 220
xdotool click 1
sleep 30
xdotool mousemove 2555 427
xdotool click 1
sleep 2
@aalemayhu
aalemayhu / fetch-page
Last active August 29, 2015 14:20
Fetch page as text file using the title for filename
#!/bin/sh
url="$1"
# http://stackoverflow.com/questions/11711339/getting-webpage-title-img-metadata-info-from-linux-terminal
title=$(wget $url -O - | grep \<title\>|sed "s/\<title\>\([^<]*\).*/\1/" | tr ' ' '_')
links -dump $url >> "$title".txt