Skip to content

Instantly share code, notes, and snippets.

@lishenzhi
lishenzhi / settings.py
Created February 8, 2019 19:23 — forked from btimby/settings.py
Use a Django database router, a TestCase mixin and thread local storage to allow unit tests to switch databases.
# Detect if executed under test
TESTING = any(test in sys.argv for test in (
'test', 'csslint', 'jenkins', 'jslint',
'jtest', 'lettuce', 'pep8', 'pyflakes',
'pylint', 'sloccount',
))
if TESTING:
# If testing, move the default DB to 'mysql' and replace it
# with a SQLite DB.
@lishenzhi
lishenzhi / bobp-python.md
Created January 18, 2018 18:49 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@lishenzhi
lishenzhi / jmeter-sha256
Last active August 10, 2023 15:41
jmeter sha256 signature
// beanshell preprocessor
import org.apache.commons.httpclient.auth.DigestScheme; // necessary imports
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.jmeter.protocol.http.control.Header;
long timestamp = System.currentTimeMillis() / 1000L;
String clientID = "***";
String clientSecret = "****";
@lishenzhi
lishenzhi / ChangePassword.java
Created July 25, 2016 16:25 — forked from zach-klippenstein/ChangePassword.java
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall (rsdio@metastatic.org), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@lishenzhi
lishenzhi / docker-toolbox_uninstall.sh
Last active January 20, 2017 14:16
docker toolbox uninstall
#!/bin/bash
# source: https://github.com/docker/toolbox/blob/master/osx/uninstall.sh
# Uninstall Script
if [ "${USER}" != "root" ]; then
echo "$0 must be run as root!"
exit 2
fi
What's missing on Rover's side:
- top_story: this endpoint is not implemented because no info in DB. Need to talk to Mark about it.
- data not completed: section, subsection, sponsor, tags. need to use the SSF's services to migrate the data
@lishenzhi
lishenzhi / gist:4d004c68aacaa7025e69
Last active March 8, 2016 19:24
Rover Loadtest ToDo List
DB side
- [Done] query distinct
- [Done] N+1 problem for postgres
- [Done] postgress connection time (pgbouncer)
- [Done] 50 problem for redis
- [] optimize content query
- [In Progress] cache machine
- [] redis config
Django side