Skip to content

Instantly share code, notes, and snippets.

@jclosure
jclosure / debian_node.js_install
Created August 28, 2013 18:07
Install node.js in Debian dists
2013-05-29
Install required build tools:
# apt-get -y install git-core curl build-essential openssl libssl-dev python pkg-config checkinstall
Create node.js package (change the 0.10.8 to the current version):
# mkdir ~/nodejs && cd ~/nodejs
# wget -N http://nodejs.org/dist/node-latest.tar.gz
# mkdir node-install
@jclosure
jclosure / wget_site_ripper
Created August 28, 2013 20:31
rip an entire website with wget
wget is a nice tool for downloading resources from the internet. The basic usage is wget url:
wget http://linuxreviews.org/
Therefore, wget (manual page) + less (manual page) is all you need to surf the internet. The power of wget is that you may download sites recursive, meaning you also get all pages (and images and other data) linked on the front page:
wget -r http://linuxreviews.org/
But many sites do not want you to download their entire site. To prevent this, they check how browsers identify. Many sites refuses you to connect or sends a blank page if they detect you are not using a web-browser. You might get a message like:
@jclosure
jclosure / cutycapt
Created September 9, 2013 00:35
cutycapt can capture web pages in multiple formats
cutycapt --url=http://www.cnn.com --out=cnn.com.svg
#supports multiple formats detected with file ext
#svg,ps,pdf,itext,html,rtree,png,jpeg,mng,tiff,gif,bmp,ppm,xbm,xpm
@jclosure
jclosure / mvn powered spring mvc
Created September 20, 2013 04:17
create a maven powered spring mvc app.
Clean and Cannonical
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
@jclosure
jclosure / xml_node_name_to_Pascal
Last active December 26, 2015 17:09
Converts between Pascal and Camel cases for xml node names. Really just operates on the first letter of the node name.
//C#
string jStrObj =
"<?xml version='1.0' encoding='UTF-8'?><DataObject><id>ea9b96a6-1f8a-4563-9a15-b1ec0ea1bc34</id><name>blah</name><processed>false</processed></DataObject>";
//to .net style property names
string camelPattern = @"(\<(?:[a-z])|\</(?:[a-z]))";
jStrObj = Regex.Replace(jStrObj, camelPattern, m => m.Value.ToUpper());
//to java style property names
@jclosure
jclosure / log4j_mdc
Last active August 29, 2015 14:04
extend log4j with MDC properties
# Setup your log4j ConversionPattern to include a new ApplicationId field
log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{ApplicationId} | %m%n
# You can now set this value in your java code like this
private void setupLogging() {
org.apache.log4j.MDC.put("ApplicationId", "XZY321");
}
@jclosure
jclosure / scheme_macros
Created July 31, 2014 02:57
The case for scheme macros
;3-state condition defined as a function
(define (3-state
value
positive-body
zero-body
negative-body)
(cond
((zero? value) zero-body)
((positive? value) positive-body)
(else negative-body)))
@jclosure
jclosure / petite-repl
Last active August 29, 2015 14:07
Setup Petite Scheme as Your REPL Within Emacs
;put this in your ~/.emacs file
;ref: http://community.schemewiki.org/?emacs-tutorial
;;; Always do syntax highlighting
(global-font-lock-mode 1)
;;; Also highlight parens
(setq show-paren-delay 0
show-paren-style 'parenthesis)
(show-paren-mode 1)
@jclosure
jclosure / find_emacs_keybindings
Created October 22, 2014 02:13
Discover Your Keybindings In Emacs
An extremely useful thing to know in emacs is how to discover what keys are bound to which commands on your own.
If you know the name of the command -- goto-line. If you type 'C-h w' (Control+h and then w), Emacs will as you "Where is command: ". Type goto-line and hit enter, and it will tell you what keystrokes (if any) are bound to that command.
There are a bunch more similar features. 'C-h k' does the inverse -- asks you for a keystroke and then tells you the command it runs; 'C-h b' shows all current keybindings; 'C-h a' will search for a string, so you might type 'C-h a goto' to search for commands with "goto" in the name; 'C-h v' describes variables; 'C-h f' describes functions; etc.
@jclosure
jclosure / brew_update_via_git
Created October 22, 2014 05:17
Update Homebrew via GIT Because Its Just a Git Repo
This can help if you have problems with: brew update
Don't forget to fetch the origin!!!
$ cd /usr/local
$ git fetch origin
$ git reset --hard origin/master