Skip to content

Instantly share code, notes, and snippets.

View magicsih's full-sized avatar

ilhwan magicsih

View GitHub Profile
@magicsih
magicsih / KeepAliveTest.java
Last active May 30, 2017 07:08
Simple Java HTTP Client Code Snippet for KeepAliveTesting
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
//============================================================================
// Name : MadProgression.cpp
// Author : magicsih
// Version :
// Copyright :
// Description : Mad Progression in C++, Ansi-style
//============================================================================
#include <iostream>
#include <fstream>
@magicsih
magicsih / dog_and_chick.cpp
Last active May 30, 2017 07:21
Algorithm: Dog and chick
//============================================================================
// Name : DogAndChick.cpp
// Author : magicsih
// Version :
// Copyright :
// Description : How many dogs and chicks in C++, Ansi-style
//============================================================================
#include <iostream>
#include <fstream>
@magicsih
magicsih / meeting_arrangement.cpp
Created May 30, 2017 07:19
Algorithm : Meeting Arrangement
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
void sort_meetings_order_by_finish(int numberOfMeetings, int **meetings);
int main()
{
@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()
@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 / 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 / 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 / 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 / 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;