Skip to content

Instantly share code, notes, and snippets.

@sooop
sooop / softDict.py
Created February 20, 2013 07:46
softDict make dictionary into another object to access key-value using .propertyname convention
#!/usr/local/bin/python
#-*-coding:utf-8
#filename:softDict.py
'''
softDict
copyright 2013. All right reserved to sooop.
'''
class SoftDict:
# *coding*: utf-8
import sqlite3
import time
# 데이터베이스 연결 생성
# 존재하지 않는 파일이라고 가정. 새 파일을 생성함
db_filename = 'test.db'
conn = sqlite3.connect(db_filename)
# 테이블 제거, 생성
function FileManager()
{
var _self = this;
this.$defaultFilename = "default-ace-file";
this.files = {};
this.currentFile = null;
this.new = _newFile;
this.save = _saveSessions;
this.load = _loadFile;
function EditorInstance(key)
{
// class variables
var _self = this;
this.key = key || _newKey();
this.wrapper = null;
this.editor = null;
this.fileManager = null;
// internal property
@sooop
sooop / distribute_setup.py
Created March 12, 2013 01:36
distribute_setup.py
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
@sooop
sooop / ANSI-C.sublime-build.json
Last active December 14, 2015 20:19
ANSI-C Build System for win32
{
"cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
[
{
"name": "Run",
@sooop
sooop / bignum.c
Created March 12, 2013 15:53
bignum.c - add very large number using strings.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// basic function
char * reverse(const char* s1);
int __strlen(const char *s1);
char * ljust(const char *s1, int length, char c);
char * ltrim(const char *s1, char c);
int max(int a, int b);
@sooop
sooop / E015.m
Last active December 14, 2015 21:18
[C] 큰 자리수의 덧셈
#import <Foundation/Foundation.h>
NSString *mutipliyStrings(NSString *str1, NSString *str2);
NSString *stringWithReversedArray(NSArray *reversedArray);
NSString *ltrim(NSString *str, unichar ch);
NSString *rjust(NSString *str, NSUInteger length, unichar ch);
NSString *addStrings(NSString *str1, NSString *str2);
NSString *factorial(NSString *str);
NSString *rjust(NSString *str, NSUInteger length, unichar ch)
#include <ctype.h>
void strupr(char *somestr)
{
while(*(somestr+i)!='\0')
{
*(somestr+i) = toupper(*(somestr+i));
somestr++;
}
}
@sooop
sooop / arr_of_string.c
Created March 14, 2013 05:44
이중포인터를 사용하여 문자열의 배열을 동적으로 할당하고 해제하는 예제.
#include <stdio.h>
#include <stdlib.h> // for calloc()
#include <string.h> // for strcpy() . not necessary because compiler will automatically include string.h. (with warning)
#define MAXNUM 50
int main(void)
{
char **arrs; // declare arrs with pointer of char pointer.
arrs = (char**)calloc(MAXNUM, sizeof(char*)); // allocate 50*4bytes to arrs. it holds address of each string array.