This is a quick guide to Kotlin programming language. The previous part of this guide is here
#Object Oriented
fun main(args : Array<String>) {
class local (val x : Int)
val y = local(10)
println("${y.x}")
- (UIViewController *)topViewController{ | |
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; | |
} | |
- (UIViewController *)topViewController:(UIViewController *)rootViewController | |
{ | |
if (rootViewController.presentedViewController == nil) { | |
return rootViewController; | |
} | |
import java.security.SecureRandom; | |
import javax.crypto.spec.PBEKeySpec; | |
import javax.crypto.SecretKeyFactory; | |
import java.math.BigInteger; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.spec.InvalidKeySpecException; | |
/* | |
* PBKDF2 salted password hashing. | |
* Author: havoc AT defuse.ca |
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>groupId</groupId> | |
<artifactId>artifactid</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>projectName</name> | |
# Basic benchmarks | |
# SET key val # 87489.06 | |
# SETRANGE key2 6 "Redis" # 75757.58 req/s | |
# INCR key 245 # 70224.72 req/s | |
# INCRBY key 245 22 # 67114.09 req/s | |
# EVAL SET key val # 46296.29 req/s | |
# SETIFHIGHER (set or update key if new value is higher than current) # 41666.67 req/s | |
# if not exists return OK , if updated return the increment , if not updated return 0 | |
SCRIPT LOAD "local c = tonumber(redis.call('get', KEYS[1])); if c then if tonumber(ARGV[1]) > c then redis.call('set', KEYS[1], ARGV[1]) return tonumber(ARGV[1]) - c else return 0 end else return redis.call('set', KEYS[1], ARGV[1]) end" |
import os | |
import posixpath | |
import urllib | |
import BaseHTTPServer | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
# modify this to add additional routes | |
ROUTES = ( | |
# [url_prefix , directory_path] | |
['/media', '/var/www/media'], |
This is a quick guide to Kotlin programming language. The previous part of this guide is here
#Object Oriented
fun main(args : Array<String>) {
class local (val x : Int)
val y = local(10)
println("${y.x}")
# Transforming the vanilla recursive fib into the iterative DP version | |
# through a series of mechanical steps. | |
# | |
# For more on converting recursive algorithms into iterative ones, see: | |
# http://blog.moertel.com/posts/2013-05-11-recursive-to-iterative.html | |
# original function | |
def fib(n): |
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.
#Setting up Nginx on Your Local System ###by Keith Rosenberg
##Step 1 - Homebrew The first thing to do, if you're on a Mac, is to install homebrew from http://mxcl.github.io/homebrew/
The command to type into terminal to install homebrew is:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/* | |
* Amount2RMB.java 2008-6-15 | |
*/ | |
package test; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Amount2RMB { | |
private static final Pattern AMOUNT_PATTERN = |