Skip to content

Instantly share code, notes, and snippets.

View fupfin's full-sized avatar

Sungchul Park fupfin

  • Woowahan Bros.
  • Seoul, South Korea
View GitHub Profile
@fupfin
fupfin / .editorconfig
Last active January 27, 2024 05:08
My default coding style
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
tab_width=8
import java.util.Arrays;
public class HashCodeFunctions
{
private final static short DEFAULT_PRIME_NUMBER = 31;
private HashCodeFunctions()
{
throw new AssertionError("Could not be instantiated.");
}
@fupfin
fupfin / MapBuilder.java
Created June 16, 2015 11:31
Simple map builder for java using Tuple class I've made before (https://gist.github.com/fupfin/2299564)
package fupfin;
import static fupfin.Tuples.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class MapBuilder<K, V> {
private Map<K, V> map = new ConcurrentHashMap<K, V>();
@fupfin
fupfin / Schwartz.java
Last active August 29, 2015 14:12
Schwartz Transform Java 8 Version
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.javatuples.*;
public class Schwartz {
public static <T> List<T> transform(List<T> list, Function<T, Integer>fn) {
return list.stream()
(defn count-change-for-us [amount] (count-change amount [1 5 10 25 50]))
(defn count-change [amount coins]
(cond (= amount 0) 1
(< amount 0) 0
(empty? coins) 0
:else (+ (count-change (- amount (first coins)) coins)
(count-change amount (rest coins)))
))
public class ChangeCounter {
int cents[] = { 50, 25, 10, 5, 1 };
public int count(int amount) {
return count(amount, 0);
}
private int count(int amount, int idx) {
if (amount == 0) {
@fupfin
fupfin / MinSumCombination.scala
Created December 8, 2014 12:09
최소값 조합 찾기
object MinSumCombination {
def findMin(nums: Array[Int]): Int = {
val result = tryCombinations(nums, 0)
if (result < Int.MaxValue) result else -1
}
private def tryCombinations(nums: Array[Int], fixPos:Int): Int = {
//println((nums).mkString(","))
if(fixPos >= nums.length - 1) Int.MaxValue
package com.fupfin.groovybase64
import java.nio.ByteBuffer
class Base64 {
static RAW_CHUNK_SIZE = 3
static ENC_CHUNK_SIZE = 4
static encChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes()
import static java.lang.System.out;
import com.google.code.jyield.*;
public class GeneratorDemo {
public static void main(String args[]) {
for(int n: YieldUtils.toIterable(take(25, sequenceOf(integers()))))
out.println(n);
}
public static Generator<Integer> take(int count, Generator<Integer> source) {
<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>org.springframework.samples</groupId>
<artifactId>myfirstspring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<!-- Generic properties -->