Skip to content

Instantly share code, notes, and snippets.

View honux77's full-sized avatar
🏠
Working from home

Hoyoung Jung honux77

🏠
Working from home
View GitHub Profile
@honux77
honux77 / class.cpp
Last active August 29, 2015 14:03
c++ inheritance example
#include <iostream>
using namespace std;
class Base
{
public:
void foo1() {
cout << "BASE foo1" << endl;
}
virtual void foo2() {
@honux77
honux77 / string.java
Created July 16, 2014 03:48
java string format
import java.util.Calendar;
public class StringTest {
public static void formatTest() {
Calendar c = Calendar.getInstance();
String strtest = String.format("μ•ˆλ…•ν•˜μ„Έμš” %dμ›” %dμΌμž…λ‹ˆλ‹€.",
c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH));
System.out.println(strtest);
}
public static void main(String[] args) {
import java.net.UnknownHostException;
import java.util.Set;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.DB;
@honux77
honux77 / pom.xml
Last active August 29, 2015 14:05
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.honux</groupId>
<artifactId>qna</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<dependencies>
</dependencies>
@honux77
honux77 / Test.java
Created September 1, 2014 07:43
Jedis Sample Test code
import redis.clients.jedis.Jedis;
public class Test {
private static long time;
private static Jedis jedis = new Jedis("localhost");
public static void main(String[] args) {
/*
jedis.set("hoyoung", "tired");
String str = jedis.get("hoyoung");
@honux77
honux77 / MakeData.java
Last active August 29, 2015 14:07
sample data generator
import java.util.Random;
public class MakeData {
static Random r = new Random();
public static void main(String[] args) {
int len = 8;
MakeData m = new MakeData();
int count = Integer.parseInt(args[0]);
m.genData(count, len);
@honux77
honux77 / wrong.c
Created October 23, 2014 07:08
wrong example for Korean letter
#include <stdio.h>
#include <string.h>
int main(void) {
char *all = "μ•ˆλ…•ν•˜μ„Έμš”";
char buf[16];
buf[0] = all[3];
buf[1] = all[4];
buf[2] = all[5];
buf[3] = '\0';
@honux77
honux77 / wchar.c
Created October 23, 2014 07:11
wchar_t example
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <locale.h>
#include <stdlib.h>
#include <time.h>
void print_name(wchar_t all[]);
int main(void) {
@honux77
honux77 / func1.c
Created October 24, 2014 03:31
address of function and others
#include <stdio.h>
#include <stdlib.h>
void foo() {printf("I am foo\n");}
int global = 10;
int main(void) {
int x = 100;
char *literal = "Hello"; //read only, literal[1] = 'h' --> error
char stack[] = "Hello"; //stack
char *heap = (char *) malloc(sizeof(char)* 6); //heap
printf("address of foo = %p\n", foo);
@honux77
honux77 / funcptr2.c
Created October 24, 2014 03:50
function ptr ex
#include <stdio.h>
#include <stdlib.h>
double pow(double x, int n) {
int i;
double ret = 1;
for (i = 0; i < n; i++) ret *= x;
return ret;
}
int main(void) {