Skip to content

Instantly share code, notes, and snippets.

View magicsih's full-sized avatar

ilhwan magicsih

View GitHub Profile
@magicsih
magicsih / bulkInsertFromFile.js
Created March 24, 2023 05:10
This Node.js script reads data from a file and inserts it into a MySQL database using bulk insert. It initializes a read stream from the file and an empty array to store the data. As the stream reads data, it converts each line from a hexadecimal string to a Buffer object and adds it to the data array. Once the data array reaches a certain size …
const fs = require('fs');
const mysql = require('mysql');
// MySQL database connection configuration
const connection = mysql.createConnection({
host: '<host>',
user: '<user>',
password: '<password>',
database: '<database>'
});
@magicsih
magicsih / random_mnemonic.js
Last active July 24, 2022 15:19
Generate random mnemonic.
const ethers = require('ethers');
const mnemonic = await ethers.utils.HDNode.entropyToMnemonic(ethers.utils.randomBytes(16));
@magicsih
magicsih / crawl-image.sh
Created March 17, 2022 04:08
Download some sequential named images from web in bash script.
#!/bin/bash
set -B
for i in {1..1000}; do
curl $path/$i.png > $i.png # replcae $path with yours
done
@magicsih
magicsih / README.txt
Last active January 3, 2022 12:47
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. [Super Urban Cat] Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=true&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
@magicsih
magicsih / AzureFunctionSample.cs
Created August 27, 2021 07:50
AzureFunction EventGrid, BlobStorageEvent
// Default URL for triggering event grid function in the local environment.
// http://localhost:7071/runtime/webhooks/EventGrid?functionName={functionname}
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.EventGrid.Models;
using Microsoft.Azure.WebJobs.Extensions.EventGrid;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System.IO;
@magicsih
magicsih / Controller.java
Last active August 28, 2021 13:32
DataTable (Front-end to Back-end)
@RequestMapping(path = "/scriptingonly/list", method = RequestMethod.GET)
public DataTable<Script> getScriptingOnlyList(@PathVariable("gameCode") String gameCode, @PathVariable("deviceOs") String deviceOs, @Valid DataTableParameter parameters, @RequestParam(name="search", required=false) String searchText) {
LOG.debug("GameCode:{} DeviceOs:{} DataTableParameter:{} SearchText:{}", gameCode, deviceOs, parameters, searchText);
DataTable<Script> scriptDataTable = scriptService.getScriptDataTable(gameCode, deviceOs, parameters, searchText);
return scriptDataTable;
}
@magicsih
magicsih / Progam.cs
Created October 4, 2019 01:40
This gist contains code snippets that let you view IdleTime managed by the Windows OS and initialize it with mouse input.
using System;
using System.Runtime.InteropServices;
using System.Threading;
namespace WindowsIdleTime
{
class Program
{
[DllImport("user32.dll", SetLastError = true)]
static extern uint SendInput(uint nInputs, ref INPUT pInputs, int cbSize);
@magicsih
magicsih / CustomProxyServlet.java
Created March 19, 2019 01:03
HttpProxyServer with Jetty 9.
public class CustomProxyServlet extends ProxyServlet {
private final Map<String, FilterableHost> filterMap;
public CustomProxyServlet() {
this.filterMap = new HashMap<>();
}
public CustomProxyServlet referHostFilterByUrl(String fromUrl, String toUrl) {
if(filterMap.containsKey(fromUrl)) {
@magicsih
magicsih / AesExample.cs
Last active May 4, 2023 12:33
AES Encryption/Decryption Example in C#
using System.Security.Cryptography;
using System.Text;
namespace AesExample
{
class Program
{
private const string ORIGINAL = "this is some data to encrypt";
private const string SAMPLE_KEY = "gCjK+DZ/GCYbKIGiAt1qCA==";
private const string SAMPLE_IV = "47l5QsSe1POo31adQ/u7nQ==";
@magicsih
magicsih / january_first_is.cpp
Created May 30, 2017 07:20
How to know what day January first is.
#include <ctime>
#include <stdio.h>
#include <iostream>
using namespace std;
bool is_leap_year(int year);
int get_wday_january_first(int yday, int wday);
int main()