Skip to content

Instantly share code, notes, and snippets.

View shao-wang-me's full-sized avatar
🔋
0.99^100 = 0.37

Shao shao-wang-me

🔋
0.99^100 = 0.37
View GitHub Profile
@tfeldmann
tfeldmann / duplicates.py
Last active January 19, 2024 23:36
Fast duplicate file finder written in python
#!/usr/bin/env python
"""
Fast duplicate file finder.
Usage: duplicates.py <folder> [<folder>...]
Based on https://stackoverflow.com/a/36113168/300783
Modified for Python3 with some small code improvements.
"""
import os
import sys
@elfnor
elfnor / md_file_tree.py
Created June 25, 2017 04:52
Generate a file tree table of contents for a directory of markdown files
# -*- coding: utf-8 -*-
"""
Generate a file tree table of contents for a directory of markdown files
run from command line:
$ python md_file_tree.py
will generate a markdown index of all markdown files in the current working
directory and its sub folders and insert it into a file `index.md`.
@jahe
jahe / jpa-cheatsheet.java
Last active May 5, 2024 09:34
JPA Cheatsheet
/*
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger:
---
entityManager.getTransaction().begin();
entityManager.persist(<some-entity>);
entityManager.getTransaction().commit();
entityManager.clear();
@dahjelle
dahjelle / pre-commit.sh
Created July 13, 2016 16:48
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done
@ryanewing
ryanewing / row_gen.py
Created April 29, 2014 20:18
pyodbc generator
def rows(cursor, size=5):
while True:
rows = cursor.fetchmany(size)
if not rows:
break
for row in rows:
yield row
connection = pyodbc.connect(driver='{SQL Server Native Client 11.0}',
server='localhost', database='master',