This file contains hidden or 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
#!/usr/bin/env zsh | |
# in fino veritas | |
# Borrowing shamelessly from these oh-my-zsh themes: | |
# fino-time | |
# pure | |
# https://gist.github.com/smileart/3750104 | |
# Set required options |
This file contains hidden or 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
def sum(li: List[Int]): Int = { | |
var total = 0 | |
for (i <- li) { | |
total = total + i | |
} | |
total | |
//只能加Int? |
This file contains hidden or 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
func sum(list []int) int { | |
var t int | |
for _, i := range list { | |
t += i | |
} | |
return t | |
} | |
//只能加總數字? |
This file contains hidden or 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
func DoAndGetInt() (int, error) { | |
//do something for long time | |
return 1, nil | |
} | |
func DoAndGetString() (string, error) { | |
//do something for long time | |
return "1", nil | |
} |
This file contains hidden or 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 csrf | |
import( | |
"encoding/base64" | |
"encoding/hex" | |
"fmt" | |
"github.com/theckman/go-securerandom" | |
) | |
const AuthenticityTokenLength = 32 |
This file contains hidden or 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
//reference http://www.baeldung.com/java-date-to-localdate-and-localdatetime | |
//LocalDate to Date | |
val date: Date = Date.from(LocalDate.now.atStartOfDay(ZoneId.systemDefault).toInstant) | |
//Date to LocalDate | |
val input = new Date | |
val ldate = input.toInstant.atZone(ZoneId.systemDefault).toLocalDate | |
//Java 9 | |
val ldate9 = LocalDate.ofInstant(input.toInstant, ZoneId.systemDefault) |
This file contains hidden or 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 java.math.BigDecimal; | |
public final class Transfer { | |
private Transfer(){} | |
public static void transfer(User from, User to, BigDecimal amount) { | |
synchronized (from) { | |
if(from.getBalance().compareTo(amount) >= 0) { | |
synchronized (to) { |
This file contains hidden or 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 java.math.BigDecimal; | |
public final class Transfer { | |
private Transfer(){} | |
public static void transfer(User from, User to, BigDecimal amount) { | |
synchronized (from) { | |
if(from.getBalance().compareTo(amount) >= 0) { | |
synchronized (to) { |
This file contains hidden or 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
object HttpCreator { | |
def createHttpClientAcceptsUntrustedCerts(cookieStore: CookieStore): CloseableHttpClient = { | |
val httpClient: CloseableHttpClient = { | |
val trustStrategy = new TrustStrategy { | |
override def isTrusted(x509Certificates: Array[X509Certificate], s: String): Boolean = true | |
} | |
val sslContext = new SSLContextBuilder().loadTrustMaterial(null, trustStrategy).build() | |
val sslSocketFactory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier) |
This file contains hidden or 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
sudo curl -sSL https://get.docker.com/ | sh | |
sudo usermod -aG docker $(whoami) | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.16.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
sudo apt-get install -y bash-completion |
NewerOlder