Skip to content

Instantly share code, notes, and snippets.

@chenrui333
chenrui333 / printFilelist_py27
Last active August 29, 2015 14:04
printout the files with subdirectory
import os
filepath_root1 = "C:\\Users\\rchen\\directory"
file_to_write = "./samplefile.txt"
with open(file_to_write, "w") as myfile:
for path, subdirs, files in os.walk(filepath_root1):
for name in files:
path = path.replace(filepath_root1, "")
myfile.write(os.path.join(path, name) + "\n")
@chenrui333
chenrui333 / findColumnInfo
Created August 6, 2014 20:51
SQLServer find the table and column info
select TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE
from Information_schema.columns
where Table_name in (
SELECT name
AS SchemaTable
FROM sys.tables
)
@chenrui333
chenrui333 / FindKeyRelationships
Created August 6, 2014 20:53
Find the Foreign Key Associated with a Given Primary Key
SELECT
o1.name AS FK_table,
c1.name AS FK_column,
fk.name AS FK_name,
o2.name AS PK_table,
c2.name AS PK_column,
pk.name AS PK_name,
fk.delete_referential_action_desc AS Delete_Action,
fk.update_referential_action_desc AS Update_Action
FROM sys.objects o1
@chenrui333
chenrui333 / GeneratePojo.py
Created August 29, 2014 20:08
Generate Pojo with SQL server auto-gen table creation SQL code
import re
import fileinput
def camelCase(st):
"""
filter nonAlpha and nonDigit char, and camelCase the output string
input:
USER_DEF1
output:
userDef1
## Test Class, JdbcTest.java
package test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
@chenrui333
chenrui333 / JsonParser
Last active August 29, 2015 14:14
Jackson-Json
## Jackson dependencies
jackson-databind
jackson-annotations
jackson-core
##
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
##
@chenrui333
chenrui333 / rename.py
Created February 25, 2015 17:29
rename the file names in the dir list
# Import the os module, for the os.walk function
import os
# Set the directory you want to start from
dirs = ['dir1', 'dir2']
prefix = 'abc'
suffix = '_abc'
for dir in dirs:
for dirName, subdirList, fileList in os.walk(dir):
print('Found directory: %s' % dirName)
@chenrui333
chenrui333 / find_LDAP_server_version
Created September 2, 2015 20:28
find LDAP server version
ldapsearch -H ldaps://xxx.harvard.edu:3131 -s base -D "cn=xxx" "(objectclass=*)" vendorversion objectClass isGlobalCatalogReady vendorname
# extended LDIF
#
# LDAPv3
# base <> (default) with scope baseObject
# filter: (objectclass=*)
# requesting: vendorversion objectClass isGlobalCatalogReady vendorname
#
#
@chenrui333
chenrui333 / interview_questions
Last active July 6, 2016 17:17
Interview questions hub
Full-stack
https://github.com/indy256/Full-stack-Developer-Interview-Questions-and-Answers
Frontend
https://github.com/h5bp/Front-end-Developer-Interview-Questions
A list of helpful front-end related questions you can use to interview potential candidates, test yourself or completely ignore.
https://github.com/khan4019/front-end-Interview-Questions
Help the front End community to rock interview http://www.thatjsdude.com/interview/index.html
@chenrui333
chenrui333 / logback.xml sample config
Last active October 21, 2015 01:51
logback.xml sample config
logback.xml sample config