Skip to content

Instantly share code, notes, and snippets.

View IngIeoAndSpare's full-sized avatar
✈️
여행가고싶다

WI-Hyun-joong IngIeoAndSpare

✈️
여행가고싶다
  • korea
View GitHub Profile
@IngIeoAndSpare
IngIeoAndSpare / fileChecker.js
Last active March 6, 2019 02:36
just study code. url file health checker.
// it just study code...
const axios = require('axios');
module.exports = {
/**
* check url file health. if request return 40X code, then chacker return false.
* @param {string} targetUrl target url string
* @param {object} headerInfo header info
* @returns {object} return object {result : (boolean)fileHealth, info : (object)headerInfo}
@IngIeoAndSpare
IngIeoAndSpare / getUserInput.js
Created March 7, 2019 04:47
get user input use readline-sync
const readLineSync = require('readline-sync');
var userInput = [],
menuText = [];
function getUserInput() {
// get user input text
for(let consoleLine of menuText) {
userInputData.push(readLineSync.question(consoleLine));
}
}
@IngIeoAndSpare
IngIeoAndSpare / dbInfo.json
Last active April 19, 2019 01:22
postgresql connect and test use pg module
{
"user" : "{{USER_NAME}}",
"userPW" : "{{USER_PASSWORD}}",
"host" : "{{DB_HOST}}",
"dbName" : "{{DB_NAME}}",
"port" : "{{PORT}}"
}
@IngIeoAndSpare
IngIeoAndSpare / fileCheckDir.cs
Created March 13, 2019 01:55
dir file checker
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace fileChecker
{
internal class Program
{
public static void Main(string[] args)
@IngIeoAndSpare
IngIeoAndSpare / getValueFromDic.cs
Created April 10, 2019 04:52
get item from ConcurrentDictionary
private string getValueFromDict(ConcurrentDictionary<string, ConcurrentDictionary<string, string>> source, string keyValue, string subKeyValue)
{
string result = null;
ConcurrentDictionary<string, string> sourceValueObject;
source.TryGetValue(keyValue, out sourceValueObject);
sourceValueObject.TryGetValue(subKeyValue, out result);
return result;
}
@IngIeoAndSpare
IngIeoAndSpare / fileRead.py
Created April 19, 2019 01:02
fileRead code
import os
def changeFilePath(file_path):
os.chdir(file_path)
def readFile(file_name) :
file_data = []
file_object = open(file_name, 'r')
while True:
line_value = file_object.readline()
@IngIeoAndSpare
IngIeoAndSpare / ImageMarshalCopy.cs
Created April 19, 2019 01:17
DDS image file convert image use marshal copy (use Pfim lib)
// filePath ex) C:\Users\User_name\Desktop\0000.dds
private System.Drawing.Image getConvertImageToDDS(string filePath)
{
try
{
//see https://github.com/nickbabcock/Pfim
Pfim.IImage pfImage = Pfim.Pfim.FromFile(filePath);
Bitmap pic = new Bitmap(pfImage.Width, pfImage.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Rectangle rect = new Rectangle(0, 0, pfImage.Width, pfImage.Height);
@IngIeoAndSpare
IngIeoAndSpare / someTip.js
Created July 30, 2019 02:55
some tip javaScript.
// 1. console log
var tile_3000 = { id : 'id_1', count : 20, vt : true};
var tile_4000 = { id : 'id_2', count : 40, vt : true};
var tile_5000 = { id : 'id_3', count : 30, vt : false};
// print object name
// set css
console.log('========= css ==============');
function convertSize(fileSize, fixed) {
var sizeName = ['Byte','KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'];
var sizeOffset = Math.round((fileSize.toString().length / 4));
var sizeReduceArray = [fileSize]
for(var loopCountNum = 0; loopCountNum < sizeOffset; loopCountNum++){
sizeReduceArray.push(1024);
}
const size = sizeReduceArray.reduce((acc, cur) => acc / cur).toFixed(fixed);
return `${size} ${sizeName[sizeOffset]}`;
@IngIeoAndSpare
IngIeoAndSpare / convertImageToBitmap.cs
Last active August 23, 2019 01:40
c# convert image to bitmap
private Bitmap convertImageToBitmap(Image targetImage)
{
Rectangle m_Rect = new Rectangle(0, 0, targetImage.Width, targetImage.Height);
Bitmap pic = new Bitmap(targetImage.Width, targetImage.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
byte[] imageData = convertImageToByteArray(targetImage);
lock (targetImage)
{
System.Drawing.Imaging.BitmapData bmpData = pic.LockBits(
m_Rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
pic.PixelFormat