I hereby claim:
- I am karlmutch on github.
- I am karlmutch (https://keybase.io/karlmutch) on keybase.
- I have a public key ASBi1fSM4ozPiy_0S-Cus0CNsEIiKaS4pNfKLBgWgvVf4Ao
To claim this, I am signing this object:
36 wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.tar.gz | |
37 javac | |
38 tar xvfo jdk-8u40-linux-x64.tar.gz | |
39 chown -R root: jdk1.8.0_40 | |
40 sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_40/bin/java 1 | |
41 sudo alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_40/bin/javac 1 | |
42 sudo alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_40/bin/jar 1 | |
43 ls | |
44 rm jdk | |
45 rm jdk-8u40-linux-x64.tar.gz |
public static BigInteger [] get_products_of_all_ints_except_at_index(BigInteger [] input) | |
{ | |
ArrayList<BigInteger> productResults = new ArrayList<BigInteger>(input.length); | |
BigInteger masterProduct = BigInteger.ONE; | |
for (BigInteger anItem : input) { | |
masterProduct = masterProduct.multiply(anItem); | |
} | |
for (BigInteger anItem : input) { |
Using Java, with no help from 3rd party libraries, there is the old way and the new way. Just sorting used to be easy with Collections.sort(..). | |
The challenge with the old way was that a lot of code was required to group the values. | |
- Input: List<String> | |
- Output: Map<Character,<List<String>> | |
- The key of map is 'A' to 'Z' | |
- Each list in the map are sorted. | |
Old Java |
func init() { | |
http.HandleFunc("/", errorHandler(betterHandler)) | |
} | |
func errorHandler(f func(http.ResponseWriter, *http.Request) error) http.HandlerFunc { | |
return func(w http.ResponseWriter, r *http.Request) { | |
err := f(w, r) | |
if err != nil { | |
http.Error(w, err.Error(), http.StatusInternalServerError) | |
log.Printf("handling %q: %v", r.RequestURI, err) |
var ( | |
Web = fakeSearch("web") | |
Image = fakeSearch("image") | |
Video = fakeSearch("video") | |
) | |
type Search func(query string) Result | |
func fakeSearch(kind string) Search { | |
return func(query string) Result { |
func WordCount(s string) map[string]int { | |
wcMap := make(map[string]int) | |
for _,word := range strings.Fields(s) { | |
if _,ok := wcMap[word] ; ok { | |
wcMap[word]++ | |
} else { | |
wcMap[word] = 1 | |
} | |
} |
package main | |
import "fmt" | |
// fibonacci is a function that returns | |
// a function that returns an int. | |
func fibonacci() func() int { | |
accum1 := 1 | |
accum2 := 0 | |
return func() int { |
// string and rune | |
const sample = "\xbd\xb2\x3d\xbc\x20\xe2\x8c\x98" | |
fmt.Printf("%x\n", sample) "bdb23dbc20e28c98" | |
fmt.Printf("% x\n", sample) "bd b2 3d bc 20 e2 8c 98" | |
fmt.Printf("%q\n", sample) "\xbd\xb2=\xbc ⌘" | |
fmt.Printf("%+q\n", sample) "\xbd\xb2=\xbc \u2318" | |
const nihongo = "日本語" |
I hereby claim:
To claim this, I am signing this object:
package main | |
import ( | |
"database/sql" | |
"errors" | |
"fmt" | |
_ "github.com/bmizerany/pq" | |
"os" | |
"regexp" | |
"strings" |