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
package main | |
import ( | |
"bytes" | |
"encoding/gob" | |
"io" | |
) | |
type Data struct { | |
A int |
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
// http://grokbase.com/p/gg/golang-nuts/12a9xcadca/go-nuts-disable-directory-listing-with-http-fileserver | |
package main | |
import ( | |
"net/http" | |
"os" | |
) | |
type NoListFile struct { |
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
//: Binary Tree | |
protocol CollectionTypeConvertible { | |
typealias T | |
var array: [T] { get } | |
} | |
class Node<T: Comparable> { | |
let value: T | |
var left: Node? |
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
public class SurrogatePair { | |
public static int convertToUTF16Index(String str, int index) { | |
int result = 0; | |
for (int i = 0; i < index && result < str.length(); i++, result++) { | |
if (result + 1 < str.length() && | |
Character.isSurrogatePair(str.charAt(result), str.charAt(result + 1))) { | |
result++; | |
} | |
} | |
return result; |
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
package com.example.recyclertest; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.GridLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import java.util.ArrayList; |
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
class Person { | |
let name: String | |
init(name: String) { self.name = name } | |
func printName() { print("name = \(name)") } | |
deinit { print("\(name) is being deinited") } | |
} | |
var p: Person? = Person(name: "Hoshi") | |
p?.printName() // name = Hoshi |
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
extension Optional { | |
func isNilOr(block: Wrapped -> Bool) -> Bool { | |
switch self { | |
case .None: | |
return true | |
case .Some(let value): | |
return block(value) | |
} | |
} | |
} |
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 <Foundation/Foundation.h> | |
const char *kindForString(NSString *str) | |
{ | |
if (str.length > 1) { | |
return "surrogate"; | |
} | |
if ([@"0123456789" containsString:str]) { | |
return "digit"; |
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
#!/bin/sh | |
old="$1" | |
new="$2" | |
if [ "x" = "x$old" -o "x" = "x$new" ] | |
then | |
echo "usage $0 old new" | |
exit 2 | |
fi |