Skip to content

Instantly share code, notes, and snippets.

@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@jseabold
jseabold / translate.py
Created December 13, 2011 18:58
Use Google Translate API from Python
# -*- coding: utf-8 -*-
"""
You need to fill in your API key from google below. Note that querying
supported languages is not implemented.
Language Code
-------- ----
Afrikaans af
Albanian sq
Arabic ar
@astrofrog
astrofrog / qsub.py
Created May 2, 2013 11:39
Submitting jobs via qsub in Python
import os
import random
import string
import tempfile
import subprocess
def random_id(length=8):
return ''.join(random.sample(string.ascii_letters + string.digits, length))
TEMPLATE_SERIAL = """
@benjamine
benjamine / README.md
Last active December 9, 2021 22:46
Delete your fork master branch, useful when using feature branches

When working with feature branches, the master branch on your fork becomes useless (you probably base your branches on upstream/master). As a result you fork's master gets outdated, and can lead to mistakes.

Deleting it is a good idea, but github needs a "default branch" to show on website, this script will create an orphan "_default" branch with just an explanatory README.md on it, and set that as default for github (you'll be asked your github password).

DISCLAIMER: This script will delete your master branch locally and remotely, be sure you don't need it anymore before running this!

@rossant
rossant / raytracing.py
Last active December 24, 2023 12:50
Very simple ray tracing engine in (almost) pure Python. Depends on NumPy and Matplotlib. Diffuse and specular lighting, simple shadows, reflections, no refraction. Purely sequential algorithm, slow execution.
"""
MIT License
Copyright (c) 2017 Cyrille Rossant
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@revolunet
revolunet / backup.py
Last active October 14, 2022 22:12
download your google drive files with python
# -*- encoding: UTF-8 -*-
import os
import httplib2
# pip install --upgrade google-api-python-client
from oauth2client.file import Storage
from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow
@alexpearce
alexpearce / offset_text.py
Last active November 5, 2020 07:03
Nice offset label formatting in matplotlib. See [the blog post](https://alexpearce.me/2014/04/exponent-label-in-matplotlib/) for more.
import numpy as np
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(5, 4))
# Generate some data
mu, sigma = 1e7, 1e6
s = np.random.normal(mu, sigma, 10000)
# Plot it
plt.hist(s, 30, histtype='step')
# Format it
@ryerh
ryerh / tmux-cheatsheet.markdown
Last active June 10, 2024 17:21 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程

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

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

启动新会话:

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

恢复会话:

@littlecodersh
littlecodersh / WechatSmartWish.py
Created September 28, 2016 03:01
Demo of sending smart wishes through wechat.
#coding=utf8
import itchat, time
SINCERE_WISH = u'祝%s新年快乐!'
REAL_SINCERE_WISH = u'祝%s新年快乐!!'
def send_wishes():
friendList = itchat.get_friends(update=True)[1:]
for friend in friendList:
# 如果不是演示目的,把下面的方法改为itchat.send即可
@ashander
ashander / comet-and-conda-errors.md
Last active June 6, 2023 01:12
Error attempting to use numpy via conda on SDSC's Comet resource --- due to default number of threads requested by OpenMP

The error below can be avoided by export OMP_NUM_THREADS=2 (or possibly a higher number). To see this run:

env OMP_NUM_THREADS=2 python -c 'import numpy'

environment

system