Skip to content

Instantly share code, notes, and snippets.

@julianbonilla
julianbonilla / gist:1770502
Created February 8, 2012 15:33
Install a JAR to a local Maven repository
# 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
#! /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])
@julianbonilla
julianbonilla / julian.el
Created May 14, 2012 19:02
Custom emacs initializations
;; 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))
@julianbonilla
julianbonilla / init.el
Created May 14, 2012 19:40
Emacs init
(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
@julianbonilla
julianbonilla / GsonTest.java
Created May 24, 2012 21:18
Read json from file into Gson
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 {
@julianbonilla
julianbonilla / gist:4236724
Created December 7, 2012 21:34
Apache on Mac OS X Mountain Lion
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
@julianbonilla
julianbonilla / gist:7217633
Created October 29, 2013 16:09
Formatted string of a date as mm/dd/yyyy.
String.format('%tm/%<td/%<tY', new Date())
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"""
(* 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.