Skip to content

Instantly share code, notes, and snippets.

View Everfighting's full-sized avatar
😁
I may be slow to respond.

蔡大锅 Everfighting

😁
I may be slow to respond.
View GitHub Profile
@eigenein
eigenein / pyDes.py
Created October 10, 2011 11:33
A pure python implementation of the DES and TRIPLE DES encryption algorithms
#############################################################################
# Documentation #
#############################################################################
# Author: Todd Whiteman
# Date: 16th March, 2009
# Verion: 2.0.0
# License: Public Domain - free to do as you wish
# Homepage: http://twhiteman.netfirms.com/des.html
#

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@ryerh
ryerh / tmux-cheatsheet.markdown
Last active October 30, 2024 08:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表 & 简明教程

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@pierdom
pierdom / conditional_update_pandas.py
Last active October 28, 2019 21:50
[Conditionally update Pandas DataFrame column] It is equivalent to SQL: UPDATE table SET column_to_update = 'value' WHERE condition #python #pandas #datascience
# set 'column_to_update' to 0 when 'condition_column' is 0
df.loc[df['condition_column'] == 0, 'column_to_update'] = 0
# or with a if-then-else scheme
df["mycol"] = np.where((df.mycol2=="test"), 0, 1)
# condition then else
@jhconning
jhconning / gist:9e0b6cf4900a46e4400d3ee6c3b517b9
Created July 4, 2017 01:29
read SQL into pandas with pymysql
import pandas as pd
import pymysql
mysql_connection = pymysql.connect(host='localhost',
user='root',
password='',
db='tutorfall2016',
charset='utf8',
cursorclass=pymysql.cursors.DictCursor)
@khornberg
khornberg / encode_decode_dictionary.py
Created August 25, 2017 12:39
python 3 base64 encode dict
"""
Given a dictionary, transform it to a string. Then byte encode that string. Then base64 encode it and since this will go
on a url, use the urlsafe version. Then decode the byte string so that it can be else where.
"""
data = base64.urlsafe_b64encode(json.dumps({'a': 123}).encode()).decode()
# And the decode is just as simple...
data = json.loads(base64.urlsafe_b64decode(query_param.encode()).decode())
# Byte encode the string, base64 decode that, then byte decode, finally transform it to a dictionary
@M0r13n
M0r13n / README.md
Last active July 25, 2024 23:53
Logging with Loguru in Flask

This is a simple example of how to use loguru in your flask application

Just create a new InterceptHandler and add it to your app. Different settings should be configured in your config file, so that it is easy to change settings.

Logging is then as easy as:

from loguru import logger

logger.info("I am logging from loguru!")

@TengdaHan
TengdaHan / ddp_notes.md
Last active November 1, 2024 05:58
Multi-node-training on slurm with PyTorch

Multi-node-training on slurm with PyTorch

What's this?

  • A simple note for how to start multi-node-training on slurm scheduler with PyTorch.
  • Useful especially when scheduler is too busy that you cannot get multiple GPUs allocated, or you need more than 4 GPUs for a single job.
  • Requirement: Have to use PyTorch DistributedDataParallel(DDP) for this purpose.
  • Warning: might need to re-factor your own code.
  • Warning: might be secretly condemned by your colleagues because using too many GPUs.
@Debbl
Debbl / Window11 Terminal WSL 安装 zsh 及前端开发环境.md
Last active June 15, 2024 09:41
Window11 Terminal WSL 安装 zsh 及前端开发环境

1. 准备

  • window 11
  • 开启适用与 Linx 的 Windows 子系统
  • 到微软商店下载 Ubuntu 系统
  • 这里我使用的是 WSL1, wsl --set-default-version <Version>

1.1 查看当前环境的 shell

echo $SHELL