Skip to content

Instantly share code, notes, and snippets.

View leoluyi's full-sized avatar
🎯
Focusing

Leo Lu leoluyi

🎯
Focusing
View GitHub Profile
import ctypes
import imp
import sys
def main():
try:
import tensorflow as tf
print("TensorFlow successfully installed.")
if tf.test.is_built_with_cuda():
@leoluyi
leoluyi / hashlib_dict.py
Last active June 26, 2018 08:59
Hashing a dictionary
import hashlib
import json
m = hashlib.sha256()
data_json = json.dumps(data_dict, ensure_ascii=False, sort_keys = True)
m.update(str(data_json).encode('utf-8'))
hashed = m.hexdigest()
print(hashed)
instance.id = hashed
@leoluyi
leoluyi / NERDTree.mkd
Created June 5, 2018 13:05 — forked from m3nd3s/NERDTree.mkd
My Vim Cheat Sheet

NERDTree

o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|

O.......Recursively open the selected directory..................|NERDTree-O|

@leoluyi
leoluyi / logging_config.py
Created May 17, 2018 08:29
Python logging settings
# from datetime import date
__all__ = ['LOGGING_CONFIG']
FILE_NAME = 'log/tag_mot.log'
LOGGING_CONFIG = {
'version': 1,
'formatters': {
'precise': {
@leoluyi
leoluyi / install_chrome.sh
Last active October 1, 2018 03:52 — forked from mrtns/gist:78d15e3263b2f6a231fe
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
@leoluyi
leoluyi / centos_cx_Oracle
Created May 2, 2018 09:39 — forked from floer32/centos_cx_Oracle
CentOS 6: Set up Oracle Instant Client and Python package cx_Oracle
#!/bin/bash
# INSTALL ORACLE INSTANT CLIENT #
#################################
# NOTE: Oracle requires at least 1176 MB of swap (or something around there).
# If you are using CentOS in a VMWare VM, there's a good chance that you don't have enough by default.
# If this describes you and you need to add more swap, see the
# "Adding a Swap File to a CentOS System" section, here:
# http://www.techotopia.com/index.php/Adding_and_Managing_CentOS_Swap_Space
@leoluyi
leoluyi / gpg-import-and-export-instructions.md
Created March 20, 2018 15:01 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@leoluyi
leoluyi / tmux.md
Created March 20, 2018 01:05 — forked from Bekbolatov/tmux.md
Clean tmux cheat-sheet

Clean tmux cheat-sheet

By resources

sessions

list-sessions        ls         -- List sessions managed by server
new-session          new        -- Create a new session
@leoluyi
leoluyi / url_shortener.py
Created March 6, 2018 05:18 — forked from aster1sk/url_shortener.py
Minimalistic URL shortener (Python/Flask/Mongo)
"""
Install : pip install pymongo flask
Minimalistic url shortener : use with curl -sd "url=http://example.com/" http://this-app.com/shorten
"""
from flask import Flask, request, redirect, abort
from pymongo import MongoClient
import base64, md5, re
con = MongoClient()
col = con.shortener.entries