Skip to content

Instantly share code, notes, and snippets.

View nibrahim's full-sized avatar

Noufal Ibrahim nibrahim

View GitHub Profile
@nibrahim
nibrahim / edit.el
Created April 13, 2010 06:49
Emacs/Zsh snippet to open files an jump to a specific line
(require 'server)
(server-start)
(defun nkv-find-file-and-jump (spec)
(interactive "s")
(let ((f (car (split-string spec ":")))
(l (cadr (split-string spec ":"))))
(find-file f)
(if l (goto-line (string-to-int l)))))
@nibrahim
nibrahim / gist:466899
Created July 7, 2010 16:19
Pomodoro timer as similar to the online focus booster as a shell script
function alarm() {
# First argument is the number of minutes spent on work (one pomodoro)
# Second argument is the rest time.
# I usually invoke this as alarm 30 5 (work for 30 minutes, rest for 5)
work_time=$(echo "$1*60" | bc)
rest_time=$(echo "$2*60" | bc)
( mpg123 --loop -1 ~/scratch/clock-ticking-4.mp3 > /dev/null 2>&1 &
mpg123pid=$!
(sleep ${work_time} &&
kill $mpg123pid &&
@nibrahim
nibrahim / nkv-session.el
Created August 3, 2010 18:18
Poor mans session management for Emacs
; Cheap and dirty session management for Emacs.
; Add the location of this file to your load-path,
; Do a (require 'nkv-session) in your .emacs
; Then hit f9 to load up your session files.
; While you work, if you want to remember a file, hit f9 in the buffer.
; If you want to remember all the current open buffers, you can simply call nkv/session-save-current-buffers
; Whenever you want to save, call nkv/save-session.
; Or you can add nkv/save-session to kill-emacs-hook to save the session upon quit automatically.
; Next time, hit f9 to reload your files.
;
@nibrahim
nibrahim / pycon-plugin-presentation.tex
Created October 22, 2010 09:19
Code samples in beamer
\documentclass {beamer}
\usepackage{graphics}
\usepackage{listings}
\usetheme{Berkeley}
\title {Plugin frameworks}
\subtitle {3 approaches to designing plugin APIs}
@nibrahim
nibrahim / line-length-sort.el
Created October 22, 2010 10:34
Sort lines by length
(defun sort-lines-by-length (b e)
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region b e)
(let ((items (sort
(split-string
(buffer-substring (point-min) (point-max)) "[\n]")
(lambda(x y) (< (length x) (length y)))))
)
@nibrahim
nibrahim / pygments-pygame.py
Created January 9, 2011 20:40
Using pygments to highlight code for use in pygame
#!/usr/bin/env python
import pygame
from pygame.locals import *
from pygame.color import Color
from pygments.lexers import PythonLexer
from pygments.styles.emacs import EmacsStyle
@nibrahim
nibrahim / pygments-pygame.py
Created January 10, 2011 19:24
Using pygments to highlight code for use in pygame Using pygments to highlight code for use in pygame
#!/usr/bin/env python
import pygame
from pygame.locals import *
from pygame.color import Color
from pygments.lexers import PythonLexer
from pygments.styles.emacs import EmacsStyle
@nibrahim
nibrahim / python-stop-here.el
Created December 14, 2011 07:31
Creating pdb breaks in a python file
(defun nkv/stop-here (pos)
(interactive "d")
(let (
(trace-command "import pdb; pdb.set_trace()")
)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(search-forward trace-command nil t)
@nibrahim
nibrahim / gist:2466292
Created April 22, 2012 19:21
Screencast make rules
ARCHIVE_DIR=/home/noufal/projects/emacsmovies.org/videos
all: generate archive
upload: generate
curl --location --header "authorization: LOW xxxx:yyyy" --upload-file ./${number}-episode-${name}.webm http://s3.us.archive.org/EmacsMovies/${number}-episode-${name}.webm
curl --location --header "authorization: LOW xxxx:yyyy" --upload-file ./${number}-episode-${name}.mkv http://s3.us.archive.org/EmacsMovies/${number}-episode-${name}.mkv
archive: ${number}-episode-${name}.webm
@nibrahim
nibrahim / Shell functions
Last active December 20, 2015 10:59
Git repository visualisation.
showrepo () {
img=$(tempfile -s.png)
~/bin/showrepo.rb $1 | dot -Tpng > $img
echo $img
qiv $img
}
showdag () {
img=$(tempfile -s.png)