Skip to content

Instantly share code, notes, and snippets.

Ramin Honary RaminHAL9001

Block or report user

Report or block RaminHAL9001

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rename-buffer.el
(defun rename-current-buffer (new-bufname)
"Prompts for a new buffer name in the minibuffer using the
current buffer name as an initial value, renames the current
buffer to the value entered."
(interactive
(let ((curbufname (buffer-name)))
(list (read-string "New buffer name: " curbufname 'buffer-name-history curbufname t))))
(rename-buffer new-bufname))
(global-set-key (kbd "C-c r b") 'rename-current-buffer)
View bash-basics--tokenizing.html
<html><head>
<style type="text/css">
div.top-level {
width: 20cm;
left-margin: 0.5cm;
right-margin: 0.5cm;
}
p, ol, td, blockquote {
font-family: serif;
color: #000000;
View unfold-to-map-and-iterate.md

Well I think you have made a wise decision to learn Haskell, but it is really unlike any programming language you have probably learned until now.

Lets first review what id and const do.

The id function is a function that doesn't change anything -- whatever you pass to it, the same value comes out unchanged. So id 5 equals 5, id False equals False id "hello" equals "hello", id () equals ().

The const function is a function that always returns the same value, no matter what you give to it. const 5 True equals 5, const 5 "hello" equals 5, const 5 () equals 5, no matter what, const 5 always returns 5.

Now, do you understand what the map and iterate do? The map function takes a list and a function and uses the function to modify each elements in the list with the function. For example:

@RaminHAL9001
RaminHAL9001 / timer.bash
Last active Aug 29, 2015
Command line oven timer program written in Bash script. Specify wait time in "hh:mm:ss" or "mm:ss" format.
View timer.bash
#!/bin/bash
# An oven timer. This script uses the "notify-send" program to display a
# message after a certain amount of time specified as command line arguments.
# It optionally plays a sound using "mplayer" after calling "notify-send".
# Waiting time can be specified in a user friendly (hours : minutes : seconds)
# format, e.g. "hh:mm:ss" or "mm:ss".
#
# Copyright (C) Ramin Honary 2014, all rights reserved.
# Licensed under the GNU General Public License:
# http://www.gnu.org/licenses/gpl.html
View Damerau-Levenshtein distance function in Java
public static int damLevDist(String A, String B) {
StringBuilder builder = new StringBuilder();
builder.append(" ");
A = A.toLowerCase(); B = B.toLowerCase();
int alen = A.length(), blen = B.length();
int maxdist = alen + blen;
int alphabet[] = new int[127];
for (int i = 0; i < alphabet.length; ++i) {
alphabet[i] = 0;
}
@RaminHAL9001
RaminHAL9001 / FoldPrec.hs
Created Jan 17, 2014
BOMDAS, PEMDAS, order of operations. Folding a list of elements where each element is paired with an operator. Providing the operators precedence and associativity, the foldPrec function will infix the elements of the list by the correct order of operations. This is the general case, so it works for anything, not just arithmetic operations.
View FoldPrec.hs
-- "Data/Function/FoldPrec.hs" fold with precedence and associativity.
--
-- Copyright (C) 2014 Ramin Honary.
--
-- The source code is free software: you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- This software is distributed in the hope that it will be useful,
You can’t perform that action at this time.