Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Reverse the digits in a number *) | |
fun reverse_num(num : int) = | |
Int.fromString( implode (rev (explode (Int.toString(num)))) ) | |
(* Test if a string is a palindrome ie. 'abba' *) | |
fun palindrome (str : string) = | |
let val str_list = explode str | |
in | |
str_list = rev str_list | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
# Generate a list of words to test for anagrams | |
perms = ['William Shakespeare', 'I am a weakish speller'] | |
words = ['abc', 'def', 'gih'] | |
for word in words: | |
perms.extend([''.join(p) for p in permutations(word)]) | |
def compute_score(word): | |
"""Given a string, compute a score from the characters""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.format('%tm/%<td/%<tY', new Date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/Sites | |
# Add user Sites directory to Apache config | |
cd /etc/apache2/users | |
sudo cp Guest.conf `whoami`.conf | |
sudo emacs `whoami`.conf | |
## M-x replace-string Guest with: YOUR_USERNAME | |
## M-x replace-string AllowOverride None with: AllowOverride All | |
## C-x C-s | |
## C-x C-c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import com.google.gson.Gson; | |
public class GsonTest { | |
public static void main(String[] args) throws FileNotFoundException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/") t) | |
(package-initialize) | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
;; Add in your own as you wish: | |
(defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Custom initializations. Loaded automatically from init.el | |
;;; Groovy Mode | |
;;; turn on syntax highlighting | |
(global-font-lock-mode 1) | |
;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start | |
(autoload 'groovy-mode "groovy-mode" "Major mode for editing Groovy code." t) | |
(add-to-list 'auto-mode-alist '("\.groovy$" . groovy-mode)) | |
(add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
def quicksort(list): | |
# Base case: single element list is sorted. | |
if list == []: | |
return list | |
pivot = list[0] | |
left = quicksort([i for i in list[1:] if i < pivot]) | |
right = quicksort([i for i in list[1:] if i >= pivot]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Template | |
mvn install:install-file -DgroupId= -DartifactId= -Dversion=1.0.0 -Dpackaging=jar -Dfile= -DgeneratePom=true | |
# Example | |
mvn install:install-file | |
-DgroupId=com.oracle | |
-DartifactId=ojdbc14 | |
-Dversion=10.2.0.3.0 | |
-Dpackaging=jar | |
-Dfile=ojdbc.jar |