sudo mysqld_safe
SELECT column FROM table
ORDER BY RAND()
LIMIT 1
def find_seq(seq, alist): | |
''' | |
Find the sequence @seq in the list @alist. | |
@seq: a list or tuple with size `m`. | |
@alist: a list or tuple with size `n`. | |
@return: True if @alist contains @seq, False otherwise. | |
Complexity: `O((n-m) * m) = O(n * m)` | |
''' |
''' | |
MIT license: http://opensource.org/licenses/MIT | |
Copyright (c) <2013> <Paulo Cheque> | |
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 furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
import os | |
from os import listdir | |
from os.path import isfile, join | |
from invoke import run, task | |
dirpath = './mypath' | |
@task | |
def resize(): | |
#http://www.imagemagick.org/Usage/resize/#resize |
import timeit | |
import random | |
def bench(stmt, setup, n=1000, repeat=10): | |
''' | |
Run `repeat` times the `timeit` with: | |
Run `n` times the `stmt` | |
''' | |
r = timeit.repeat(stmt, setup=setup, number=n, repeat=repeat) |
Network | |
================================ | |
ping ip/dns | |
telnet ip/dns:port | |
netstat | |
http | |
iptables | |
sudo lsof -i :5955 # check which process is using port 5955 |
import json | |
import re | |
import timeit | |
import ujson | |
import simplejson | |
# from memory_profiler import profile | |
# @profile(precision=4) |
mv file.pem ~/.ssh/ | |
chmod 400 ~/.ssh/file.pem | |
ssh -v -i ~/.ssh/file.pem ubuntu@ip | |
scp -i ~/.ssh/file.pem file ubuntu@ip:~ | |
scp -i ~/.ssh/file.pem ubuntu@ip:~/file . | |
http --follow POST url attr=value attr2=value2 --print=h | |
http GET url --print=h |
1 https://github.com/steelThread/redmon
2 https://github.com/joeferner/redis-commander