Skip to content

Instantly share code, notes, and snippets.

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
/**
* Created by LikeJust on 2017-08-19.
* TODO: Question
*/
public class HuWa {
static public void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, CloneNotSupportedException {
System.out.println();
@yongjun823
yongjun823 / PIL_image_save.py
Created August 19, 2017 09:04
PIL : image resize & draw rectangle
from PIL import Image, ImageDraw
im = Image.open(img_path + filter_files[0]) # path
im = im.resize((img_y_size, img_x_size), 1)
draw = ImageDraw.Draw(im)
draw.rectangle(((0, 0), (100, 100)), outline='red')
im.save('result.jpg', 'JPEG')
@yongjun823
yongjun823 / MyData.java
Last active August 20, 2017 14:22
java object serialize example for my friend
import java.io.Serializable;
// custom data class
// must implements Serializable
public class MyData implements Serializable {
int id;
String name;
MyData(int id, String name) {
@yongjun823
yongjun823 / pangram.c
Created August 20, 2017 14:38
pangram check solution only alphabet
int is_pan(const char *str)
{
int arr[26] = { 0 };
int i=0;
while (str[i] != '')
{
++arr[(str[i++] | 32) - 'a'];
}
@yongjun823
yongjun823 / file_rename.py
Created September 11, 2017 19:06
name rename in folder
import os
for idx, name in enumerate(os.listdir('.')):
os.rename(name, str(idx) + '.png')
@yongjun823
yongjun823 / tfrecord_create.py
Last active April 30, 2019 18:02
tensorflow object detection api) tfrecord create code
import tensorflow as tf
import numpy as np
import base64
import csv
import os
from PIL import Image
from utils import dataset_util
"""
csv format
@yongjun823
yongjun823 / libcurlex.c
Created November 28, 2017 17:14
naver nmt == libcurl & jSON
#include <stdio.h>
#include <curl/curl.h>
int main()
{
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://openapi.naver.com/v1/papago/n2mt");
import numpy as np
import pandas as pd
import tensorflow as tf
train = pd.read_csv("data_bike/train.csv", parse_dates=["datetime"])
test = train[:2000]
train= train[2000:]
feature=['temp', 'atemp', 'humidity', 'windspeed', 'casual', 'registered']
@yongjun823
yongjun823 / mapAPI.java
Created December 18, 2017 10:28
google map api - geocoding, direct
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.maps.DirectionsApi;
import com.google.maps.GeoApiContext;
import com.google.maps.GeocodingApi;
import com.google.maps.errors.ApiException;
import com.google.maps.model.DirectionsResult;
import com.google.maps.model.GeocodingResult;
import com.google.maps.model.TravelMode;
@yongjun823
yongjun823 / realtime.java
Created December 21, 2017 12:34
DataSnapshot
Iterable<DataSnapshot> dataSnapshots = dataSnapshot.getChildren();
for (DataSnapshot tempSnapshot : dataSnapshots) {
String value = tempSnapshot.getValue().toString();
String key = tempSnapshot.getKey();
if (key.equals("num")) {
Log.e(TAG, value);
} else if (key.equals("value")) {
Log.e(TAG, value);