Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
๐Ÿ˜Š
Hi

NaniteFactory

๐Ÿ˜Š
Hi
View GitHub Profile
@NaniteFactory
NaniteFactory / get_string_in_between.go
Last active July 16, 2018 14:14
GetStringInBetween() with a bug fix
package main
import (
"fmt"
"strings"
)
func main() {
str := []byte("sdfsdffio jeo <!--foo wij ewie jo fwiejwoeifjwoeifjoweifjo --> weifj ow ejowifj woesdfsdffio jeo <!--bar wij ewie jo fwiejwo2222222222eifjwoeifjoweifjo --> weifj ow ejowifj woe<!--bars -->")
fmt.Println(GetStringInBetween(string(str), "<!--foo ", " -->"))
@NaniteFactory
NaniteFactory / from_json_to_map.go
Last active July 17, 2018 11:28
Parse & convert JSON into a map
package main
import (
"encoding/json"
"fmt"
)
func main() {
data := []byte(`{"sendMsg":{"user":"ANisus","msg":"Trying to send a message"},"say":"Hello"}`)
@NaniteFactory
NaniteFactory / io_reader_to_writer.go
Created July 15, 2018 12:50
From io.Reader to io.Writer
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
)
@NaniteFactory
NaniteFactory / git-bash-here.reg
Created June 25, 2018 17:53
"Git Bash here" context menu item // Registry exports directly from the Windows installer.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell]
@="Git Ba&sh Here"
"Icon"="D:\\Program Files\\Git\\git-bash.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\git_shell\command]
@="\"D:\\Program Files\\Git\\git-bash.exe\" \"--cd=%v.\""
@NaniteFactory
NaniteFactory / detect-jre.reg
Last active June 21, 2018 18:49
(EXAMPLE) Registry for legacy applications that cannot detect JRE version >= 1.9
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment]
"CurrentVersion"="1.8"
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8]
"JavaHome"="D:\\Program Files\\Java\\jre-10.0.1"
"RuntimeLib"="D:\\Program Files\\Java\\jre-10.0.1\\bin\\server\\jvm.dll"
@NaniteFactory
NaniteFactory / memset.asm
Created June 13, 2018 07:08
memset() - fills a specified (ecx) amount of memory (at [edi]) with a given value (in eax).
lea edi,[ebp-000000CC]; 8D BD 34FFFFFF
mov ecx,00000033; B9 33000000
mov eax,CCCCCCCC; B8 CCCCCCCC
repe stosd; repeat until equal(zero flag 1) - store string dword of accumulator(eax)
@NaniteFactory
NaniteFactory / _msys2-here.reg
Last active June 8, 2018 14:54
"MSYS2 here" context menu item // MSYS ์‹คํ–‰ ์˜ต์…˜์„ ์šฐํด๋ฆญ ๋ฉ”๋‰ด์— ์ถ”๊ฐ€ํ•˜๊ธฐ
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\MSYS2 here]
@="MSYS2 here"
"icon"="D:\\msys64\\msys2.ico"
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\MSYS2 here\command]
@="D:\\msys64\\msys2.exe bash"
@NaniteFactory
NaniteFactory / Solution.java
Created April 14, 2018 08:09
4012. [๋ชจ์˜ SW ์—ญ๋Ÿ‰ํ…Œ์ŠคํŠธ] ์š”๋ฆฌ์‚ฌ ----- ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š” ๋งค์šฐ ๋”๋Ÿฌ์šด ํ’€์ด
import java.util.*;
import java.io.*;
public class Solution {
public static void swap(int[] arr, final int i1, final int i2) {
int tmp = arr[i1];
arr[i1] = arr[i2];
arr[i2] = tmp;
}
@NaniteFactory
NaniteFactory / Solution.java
Created April 14, 2018 08:00
4013. [๋ชจ์˜ SW ์—ญ๋Ÿ‰ํ…Œ์ŠคํŠธ] ํŠน์ดํ•œ ์ž์„
import java.util.*;
import java.io.*;
public class Solution {
public static int S = 1, N = 0, RIGHT = 1, LEFT = -1;
public static void rotateLeft(int[] gear) {
int tmp = gear[0];
for (int i = 0; i < gear.length - 1; ++i) {
@NaniteFactory
NaniteFactory / Solution.java
Last active April 14, 2018 06:26
1767. [SW Test ์ƒ˜ํ”Œ๋ฌธ์ œ] ํ”„๋กœ์„ธ์„œ ์—ฐ๊ฒฐํ•˜๊ธฐ ---- ํ‹€๋ฆฐ ๋‹ต ---- ์–ด๋””๊ฐ€ ํ‹€๋ ธ์ง€?
import java.util.*;
import java.io.*;
public class Solution {
public static boolean isAvailableWest(int[][] mat, int nrow, int ncol) {
for (int i = 0; i < ncol; ++i) {
if (mat[nrow][i] == 1 || mat[nrow][i] == 2) {
return false;
}