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
private void writeJsonOnResponse( | |
Object value, | |
HttpServletResponse response | |
) throws IOException { | |
String failJsonResponse = objectMapper.writeValueAsString(value); | |
response.setContentType(MediaType.APPLICATION_JSON_VALUE); | |
PrintWriter writer = response.getWriter(); | |
writer.write(failJsonResponse); | |
writer.flush(); | |
} |
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
public class FieldErrorDetail { | |
private String rejectedField; | |
private String cause; | |
} |
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
@Bean | |
public CorsFilter corsFilter() { | |
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | |
CorsConfiguration corsConfiguration = new CorsConfiguration(); | |
corsConfiguration.setAllowCredentials(true); | |
corsConfiguration.addAllowedOriginPattern("*"); | |
corsConfiguration.addAllowedHeader("*"); | |
corsConfiguration.addAllowedMethod("*"); | |
source.registerCorsConfiguration("/**", corsConfiguration); | |
return new CorsFilter(source); |
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 lombok.AllArgsConstructor; | |
import lombok.Getter; | |
@Getter | |
@AllArgsConstructor | |
public class ApiResponse <T> { | |
private final boolean success; | |
private final T result; | |
private final String message; |
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
def convert(base, value): | |
expr = "0123456789ABCDEF" | |
result = '' | |
while value >= base: | |
result = expr[value % base] + result | |
value = int(value / base) | |
return expr[value] + result | |
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
class IntParser{ | |
public static void parse(String s){ | |
int i = -1; | |
for(char ch: s.toCharArray()){ | |
if(ch >= '0' && ch <= '9'){ | |
if(i < 0) i = 0; | |
i = i * 10 + ch - '0'; | |
} else { | |
if(i >= 0) System.out.println(i); | |
i = -1; |
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
class SquareRootFinder { | |
public static int getMaxRoot(int n){ | |
for(int index = n; index > 1; index--){ | |
double root = Math.pow(index, 0.5); | |
if(root == Math.floor(root)) return index; | |
} | |
return -1; | |
} | |
} |
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
class NumberChanger { | |
public static int change(int value, int position, int to) { | |
if(position < 1 || value < 1 || to > 9 || to < 0) return -1; | |
int remove = (int)Math.pow(10, position); | |
int remains = (int)Math.pow(10, position - 1); | |
if(remains > value) return -1; | |
int retVal = value - value % remove + value % remains + to * remains; | |
return retVal; |
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 requests | |
password = '' | |
password_length = -1 | |
URL = 'https://los.rubiya.kr/chall/assassin_14a1fd552c61c60f034879e5d4171373.php' | |
headers = {'Content-Type': 'application/json; charset=utf-8'} | |
cookies = {'PHPSESSID': 'INSERT_YOUR_COOKIE_HERE'} |
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
using System; | |
class HelloWorld | |
{ | |
static void Main() | |
{ | |
String output = "1"; | |
for (int i = 1; i < 20; i++) | |
{ | |
int[] typeCount = new int[10]; // from 0 to 9 |