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 java.util.Collection; | |
import java.util.List; | |
import java.util.Set; | |
import org.apache.shiro.cache.Cache; | |
import org.apache.shiro.cache.CacheException; | |
import org.springframework.data.redis.core.RedisTemplate; | |
import org.springframework.data.redis.core.SetOperations; | |
public class ShiroRedisCache<K, V> implements Cache<K, V> { |
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 | |
SERVICE_NAME=MyService | |
PATH_TO_JAR=/usr/local/MyProject/MyJar.jar | |
PID_PATH_NAME=/tmp/MyService-pid | |
case $1 in | |
start) | |
echo "Starting $SERVICE_NAME ..." | |
if [ ! -f $PID_PATH_NAME ]; then | |
nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null & | |
echo $! > $PID_PATH_NAME |
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 java.util.function.Consumer; | |
import java.util.function.Function; | |
public class Currying { | |
public static void main(String[] args) { | |
MyFileHelper.using(new MyFile("my-file")).accept(myFile -> myFile.print()); | |
} |
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.ifp.config; | |
import org.apache.velocity.Template; | |
import org.apache.velocity.context.Context; | |
import org.apache.velocity.exception.ResourceNotFoundException; | |
import org.springframework.boot.web.servlet.view.velocity.EmbeddedVelocityToolboxView; | |
import org.springframework.core.NestedIOException; | |
import javax.servlet.http.HttpServletResponse; | |
import java.io.StringWriter; |
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 scala.collection.mutable.ListBuffer | |
/** | |
* Created by User on 10/28/2016. | |
*/ | |
object LongestAbsoluteFilePath { | |
class Node(val name: String, val depth: Int) { | |
val nodeType: NodeType.Value = getNodeType(name) |
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
object Permutations { | |
def permutations[A](s: Set[A]): List[List[A]] = { | |
if (s.size == 1) List(s.toList) | |
else s.flatMap(x => permutations(s - x).map(p => List(x) ::: p)).toList | |
} | |
def main(args: Array[String]): Unit = { | |
println(permutations(Set(1, 2, 3)).mkString("\n")) | |
} |
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 scala.collection.mutable.ListBuffer | |
/** | |
* Created by User on 11/9/2016. | |
*/ | |
object UniquePairs { | |
def uniquePairs(n: Int): List[List[Int]] = { | |
(1 to n).flatMap(i => (1 until i).map(j => List(i, j))).toList | |
} |
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.winry | |
/** | |
* Created by User on 12/13/2016. | |
*/ | |
object Aggcow { | |
def maxDistance(stalls: List[Int], cow: Int): Int = { | |
stalls.sorted | |
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.aemobile.pool; | |
/** | |
* Created by winry on 2019/7/19. | |
*/ | |
public class SimpleConnection implements Connection { | |
private String server; | |
public SimpleConnection(String server) { |
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 java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.function.Predicate; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; |
OlderNewer