Skip to content

Instantly share code, notes, and snippets.

@cwon
cwon / SimpleClient.py
Last active October 19, 2017 06:19
SimpleCM
# Client
from multiprocessing.connection import Client
address = ('localhost', 6000)
conn = Client(address)
conn.send('test')
@cwon
cwon / client
Created October 20, 2017 10:45
SimplePy3SocketStringServer-Client
from socket import *
s_socket = socket(AF_INET, SOCK_STREAM)
s_socket.connect(("localhost", 6000))
while (True):
s_socket.send('Test\n'.encode())
@cwon
cwon / ChangeCategory.py
Last active October 20, 2017 20:34
ChangeCategory
from selenium import webdriver
#browser = webdriver.Firefox()
browser = webdriver.Chrome()
browser.get("http://movie.naver.com/movie/bi/pi/filmo.nhn?code=71351")
browser.switch_to.frame("filmoContentsIframe");
browser.find_elements_by_css_selector('#filmoOrder')[0].click()
menus = browser.find_elements_by_css_selector('#filmoOrderLayer ul li a')
// ReadBMjuP.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <list>
@cwon
cwon / simpleGolangBuildPattern.go
Created November 28, 2017 15:17
simpleGolangBuildPattern
package main
import (
"fmt"
)
type result struct {
src_text string
result_sz string
is_done bool
@cwon
cwon / operator-assign.py
Last active December 5, 2017 10:24
operator-assign
import operator
# https://docs.python.org/3/library/operator.html
myOp = operator.and_
print bool( myOp(myOp(3==3,1==1), myOp(2==2, 1==1)) )
@cwon
cwon / BooleanList.py
Created February 26, 2018 08:20
BooleanList
import collections.abc
class CustomData():
def __init__(self, iterable):
self.value = []
for value in iterable:
self.value.append(value)
def __eq__(self, value):
ret = []
for v in self.value:
@cwon
cwon / gist:00ecdf0c873d75f7258ca358dede8d40
Last active June 27, 2018 04:22
get_nth_of_today.py
import datetime as dt
today = dt.datetime.now()
days_in_the_year = (dt.date(today.year, today.month, today.day) - dt.date(today.year,1,1)).days + 1
print(days_in_the_year)
@cwon
cwon / try.py
Last active August 2, 2018 14:50
facebook_get_some_set
from collections import OrderedDict, Counter
import pprint
def main():
dict_data = {
'list_1':[1, 2, 3, 4, 5, 6],
'list_2':[1, 5, 6, 7, 8, 9],
'list_3':[10, 11, 12, 13, 14, 15],
'list_4':[132, 14, 134, 135, 136, 137],
'list_5':[232, 214, 224, 235, 236, 237],
@cwon
cwon / gist:7ce75c2cbc348b01684f74b08b98b647
Created August 13, 2018 00:06
sqlalchemy_(pandas_df=>sqlite)
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:')
n=9999
df = pd.DataFrame(np.random.randn(n, 2))
df.columns = ['a','b']
df = df.astype('float32')
df.to_sql('data_chunked', con=engine, chunksize=(499), index=None)