Saturday, November 12, 2011

Testing dynamic typed code can detect much wider range of errors?

http://en.wikipedia.org/wiki/Static_typing#Dynamic_typing

the testing done to ensure correct program operation can detect a much wider range of errors than static type-checking

Saturday, October 22, 2011

Language designer's notebook: First, do no harm

Language designer's notebook: First, do no harm
Use map-reduce to sum size of all the elements rather than modify local sum variable from within a closure

Functional thinking: Coupling and composition

Neal Ford: Functional thinking: Coupling and composition, Part 1
Neal Ford: Functional thinking: Coupling and composition, Part 2


Tuesday, September 27, 2011

Mind-map to Presentation

http://www.exampler.com/blog/2009/02/04/getting-invited-to-speak-part-1
http://www.exampler.com/blog/2009/02/05/getting-invited-to-speak-part-2

http://www.lifehack.org/articles/communication/from-mind-map-to-presentation.html

http://blog.mindjet.com/2009/02/how-to-make-a-great-presentation-mapping-your-content
http://blog.mindjet.com/2009/03/presentation-camp
http://blog.publishedandprofitable.com/2008/11/11/mindmanager-template-for-authors-writing-a-speech-to-promote-their-book/
http://blog.mindjet.com/2009/02/mapping-a-great-presentation
http://www.garrreynolds.com/Presentation/slides.html
http://www.davidleeking.com/2008/09/05/presentation-tips/

10 Tips to Do Presentations Like Me:
  1. Don’t Use Templates
  2. Use Presenter Notes
  3. Use Presenter View
  4. Learn Your PC
  5. Use Screenshots
  6. Do What You Said You’d Do
  7. Tidy up Those Transitions
  8. Rehearse
  9. Interact with the Audience
  10. It’s a Performance

Thucydides


OO

Monday, September 26, 2011

Groovy Regex

http://groovy.codehaus.org/Regular+Expressions

// simple group demo
// You can also match a pattern that includes groups.  First create a matcher object,
// either using the Java API, or more simply with the =~ operator.  Then, you can index
// the matcher object to find the matches.  matcher[0] returns a List representing the
// first match of the regular expression in the string.  The first element is the string
// that matches the entire regular expression, and the remaining elements are the strings
// that match each group.
// Here's how it works:
def m = "foobarfoo" =~ /o(b.*r)f/
assert m[0] == ["obarf", "bar"]
assert m[0][1] == "bar"
 
 

XML & HTML Slurping with Groovy

XML Slurping String Content:
GPathResult feed = new XmlSlurper().parseText(source)
def rows = feed.FORM[0].TABLE[0].TR[1..-1]
// ...

Note: element names are case-sensitive

HTML Slurping with TagSoup:
slurper = new XmlSlurper(new org.ccil.cowan.tagsoup.Parser())
url = new URL("http://...")
url.withReader { reader ->
    def html = slurper.parse(reader)
    // ...
}

HTML Slurping with NekoHtml:
slurper = new XmlSlurper(new org.cyberneko.html.parsers.SAXParser())
new URL(url).withReader { reader ->
    def html = slurper.parse(reader)
    // ...
}

Friday, September 23, 2011

Cloning GitHub From Behind Proxy – Building Gradle From Source

How to clone a GitHub fork (Gradle in this case) from behind a proxy on a Windows machine without admin privileges…
  1. [Windows] Download Portable Git from: http://code.google.com/p/msysgit/downloads/list?can=3
  2. Follow instructions here:  http://help.github.com/win-set-up-git/
  3. Using git-bash: export http_proxy=http://proxyuser:passwd@proxy:port
  4. Setup /h/.ssh/config as per: http://stackoverflow.com/questions/5103083/problem-of-testing-ssh-in-git-behind-proxy-on-window-7
    ProxyCommand /c/dev/opt/git/bin/connect.exe -H proxy:port %h %p
    
    Host github.com
    User git
    Port 22
    Hostname github.com
    IdentityFile "/<userhome>/.ssh/id_rsa"
    TCPKeepAlive yes
    PreferredAuthentications publickey
    IdentitiesOnly yes
    
    Host ssh.github.com
    User git
    Port 443
    Hostname ssh.github.com
    IdentityFile "/<userhome>/.ssh/id_rsa"
    TCPKeepAlive yes
    PreferredAuthentications publickey
    IdentitiesOnly yes 


  5. git clone https://mattcallanan@github.com/mattcallanan/gradle.git gradle

    1. Provide proxy password
  6. Add the following to <project-dir>/gradle.properties:
        systemProp.http.proxyHost=proxy
        systemProp.http.proxyPort=port
        systemProp.http.proxyUser=username
        systemProp.http.proxyPassword=password
        systemProp.http.nonProxyHosts=myrepo|localhost
  7. If you have a hosted Maven repo, change gradle/build.gradle:
    ivy {
        // artifactPattern('http://repo.jfrog.org/artifactory/gradle-plugins-snapshots/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]')
        artifactPattern('http://myrepo/content/repositories/public/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]')
        ...
    } 


  8. [OPTIONAL] Proxy settings for For Ivy (not sure if this is necessary):


    • set ANT_OPTS=-Dhttp.proxyHost=proxy -Dhttp.proxyPort=port -Dhttp.proxyUserName=username -Dhttp.proxyPassword=password -Dhttps.proxyHost=proxy -Dhttps.proxyPort=port

  9. It seems minlog is in between com.esotericsoftware and com.googlecode, i.e. it’s moved but there’s still some old dependencies on esotericsoftware.  Download com.esotericsoftware:minlog:1.2 jar and pom, upload to your Maven repo, add repositories
    repositories {
        ...
        mavenCentral()
        mavenRepo(url: 'http://myrepo/content/repositories/public')
        ...
    }


Still working through some dependency issues attempting to build Gradle…

Ruby

http://mislav.uniqpath.com/poignant-guide/book/chapter-3.html

Constants are capitalised
Symbols are prefixed with a colon and are lightweight strings

Question marks and exclamation marks can be used in method names

Class methods are invoked with double colon '::' instead of a '.'

Global variables begin with '$'

Instance variables begin with '@'  ("attribute")
Class variables begin with '@@'  ("attribute all")

Code blocks can be surrounded with either {} or do-end
Block variables are surrounded by | and separated by commas.  E.g.
{ |x,y| x + y }

Range.  E.g. (1..3)  ('a'..'z')


Hashes: {'a' => 'aardvark', 'b' => 'badger'}

Regexp: /ruby/, /[0-9]+/ and /^\d{3}-\d{3}-\d{4}/




Thursday, September 22, 2011

Reverse AJAX