Skip to content

Instantly share code, notes, and snippets.

View artagnon's full-sized avatar

Ramkumar Ramachandra artagnon

View GitHub Profile
@artagnon
artagnon / upload.py
Created September 30, 2009 04:40
codereview-upload.py
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@artagnon
artagnon / fetchlyrics.sh
Created October 27, 2009 18:50
fetchlyrics.sh
#-*- Mode:sh -*-
#!/bin/sh
listindex=`head -n 1 "$HOME/.plait/status"`
np=`awk '{if(NR==n) print $0}' n=$listindex $HOME/.plait/plaiter.m3u`
np=${np#"/home/artagnon/music"/}
artist=${np%%/*} # First string before /
track=${np##*/} # Last string after /
track=${track%%.*} # remove extension
track=${track#* } # remove number
perl $HOME/bin/LeoLyrics.pm "$artist" "$track"
#!/usr/bin/perl
package Lyrics::Fetcher::LeosLyrics;
our $VERSION = 0.02;
# Copyright (c) 2007 Edward Allen III. Some rights reserved.
#
## This program is free software; you can redistribute it and/or
## modify it under the terms of the Artistic License, distributed
## with Perl.
#
@artagnon
artagnon / reformat-hard-wrapped.el
Created January 19, 2010 16:48
Reformat hard wrapped lines in Emacs
;; Reformat hard-wrapped regions
(defun reformat-hard-wrap (beg end)
(interactive "r")
(shell-command-on-region beg end "fmt -w2000" nil t))
normalize <- function (m) {
result <- m
for (r in 1:dim (m)[1]) {
avg <- mean (m [r,], na.rm=TRUE)
variance <- var (m [r,], na.rm=TRUE)
result [r,] <- result [r,] - avg
result [r,] <- result [r,] / sqrt (variance)
}
return (result)
}
@artagnon
artagnon / define-new-c-style.el
Created July 22, 2010 17:47
Path-specific style switching for Emacs
((defmacro define-new-c-style (name derived-from style-alists tabs-p path-list)
`(progn
(add-hook 'c-mode-common-hook
(lambda ()
(c-add-style ,name
'(,derived-from (c-offsets-alist
,style-alists)))))
(add-hook 'c-mode-hook
(lambda ()
(let ((filename (buffer-file-name)))
@artagnon
artagnon / smart-vs-dumb-pointer.ll
Created November 12, 2015 20:51
Smart pointer versus dumb pointer (code generation impact)
; ModuleID = 'dumb.cpp'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
; Function Attrs: ssp uwtable
define i32 @main() #0 {
entry:
%retval = alloca i32, align 4
%Dumb = alloca i32*, align 8
store i32 0, i32* %retval, align 4
@artagnon
artagnon / recipe.sh
Last active December 12, 2015 04:28
pyjnius_testing/ P4A recipe
#!/bin/bash
VERSION_pyjnius_testing=
URL_pyjnius_testing=https://github.com/kivy/pyjnius/archive/extend_class_support.zip
DEPS_pyjnius_testing=(python)
MD5_pyjnius_testing=
BUILD_pyjnius_testing=$BUILD_PATH/pyjnius/$(get_directory $URL_pyjnius_testing)
RECIPE_pyjnius_testing=$RECIPES_PATH/pyjnius_testing
function prebuild_pyjnius_testing() {
@artagnon
artagnon / cython-mode.el
Created February 7, 2013 05:35
My Cython mode
;; Cython mode
;; Load python-mode if available, otherwise use builtin emacs python package
(when (not(require 'python-mode nil t))
(require 'python))
(add-to-list 'auto-mode-alist '("\\.pyx\\'" . cython-mode))
(add-to-list 'auto-mode-alist '("\\.pxd\\'" . cython-mode))
(add-to-list 'auto-mode-alist '("\\.pxi\\'" . cython-mode))
@artagnon
artagnon / claytext.rb
Created February 17, 2013 17:06
A part of claytext.rb from artagnon/clayoven
def process!(body)
htmlescape_rules = {
"&" => "&amp;",
"\"" => "&quot;",
"'" => "&#39;",
"<" => "&lt;",
">" => "&gt;"
}.freeze
paragraph_types = [:plain, :emailquote, :codeblock, :header, :footer]