Skip to content

Instantly share code, notes, and snippets.

winry fwrq41251

Block or report user

Report or block fwrq41251

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SimpleConnection.java
package com.aemobile.pool;
/**
* Created by winry on 2019/7/19.
*/
public class SimpleConnection implements Connection {
private String server;
public SimpleConnection(String server) {
@fwrq41251
fwrq41251 / Aggcow.scala
Last active Dec 13, 2016
SPOJ Aggressive cows
View Aggcow.scala
package com.winry
/**
* Created by User on 12/13/2016.
*/
object Aggcow {
def maxDistance(stalls: List[Int], cow: Int): Int = {
stalls.sorted
View UniquePairs.scala
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
}
View Permutations.scala
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"))
}
View LongestAbsoluteFilePath.scala
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)
@fwrq41251
fwrq41251 / EmbeddedVelocityLayoutView.java
Created Aug 8, 2016
spring boot with velocity layout view.
View EmbeddedVelocityLayoutView.java
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;
View using and currying in java
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());
}
@fwrq41251
fwrq41251 / start.sh
Created Feb 29, 2016
start and stop java application from shell.
View start.sh
#!/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
@fwrq41251
fwrq41251 / ShiroRedisCache.java
Last active Feb 19, 2016
shiro cache impl in redis.
View ShiroRedisCache.java
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> {
You can’t perform that action at this time.