Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / mysql-backup-windows.bat
Created March 14, 2011 14:50
Backup MySQL databases in separate gzipped sql files on Windows
@echo off
set dbUser=root
set dbPassword=password
set backupDir="C:\Documents and Settings\user\Desktop\backup\mysql"
set mysqldump="C:\Program Files\MySQL\MySQL Workbench 5.2 CE\mysqldump.exe"
set mysqlDataDir="C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data"
set zip="C:\Program Files\7-Zip\7z.exe"
:: get date
@appden
appden / reload.bash
Created March 27, 2011 18:27
Reload your bash profile in all open bash instances
# put this in your bash profile (change the line below if you use .bash_profile)
# refresh profile on USR1 signal
trap 'eval $(PATH= /usr/libexec/path_helper -s) && source ~/.profile' USR1
# send USR1 signal to all bash instances
reload() {
ps -xo pid,command | grep ' \-bash' | awk '{print $1}' | while read pid; do
kill -USR1 $pid
done
@foxwoods
foxwoods / validate_rid.js
Created February 13, 2012 15:56
身份证号验证函数 | Validation function for Chinese I.D. card number
function validate_rid(id) {
// 18位身份证号
// 国家标准《GB 11643-1999》
function rid18(id) {
if(! /\d{17}[\dxX]/.test(id)) {
return false;
}
var modcmpl = function(m, i, n) { return (i + n - m % i) % i; },
f = function(v, i) { return v * (Math.pow(2, i-1) % 11); },
s = 0;
@supairish
supairish / gist:2951524
Created June 18, 2012 23:58
Nginx - how to limit requests by User Agent
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@vdel26
vdel26 / nginx
Last active March 16, 2023 20:31
Openresty init.d script
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@pankajp
pankajp / serve_http.py
Last active February 5, 2024 17:51
Simple Python HTTP Server with multi-threading and partial-content support
#! /usr/bin/env python
# Standard library imports.
from SocketServer import ThreadingMixIn
import BaseHTTPServer
import SimpleHTTPServer
import sys
import json
import os
from os.path import (join, exists, dirname, abspath, isabs, sep, walk, splitext,
@jamesbrink
jamesbrink / gist:a1f08818f81883c2e0cb
Last active April 22, 2018 16:58
Bumblebee & VMware Workstation setup
# Enable VMware guests to have 3d acceleration with bumblbee setups on linux. Use this if you are received the popup messages about no 3d support in guests and you are using bumblebee with optimus or primusrun
echo "mks.gl.allowBlacklistedDrivers = TRUE" >> ~/.vmware/preferences
optirun vmware
@mariotaku
mariotaku / README.md
Last active July 3, 2022 03:55
删除当前屏幕所有微博

删除所有微博

在Chrome Dev Tools中粘贴代码到Console,就可以删除当前屏幕所有微博。经过测试一万条微博大约需要10小时的半人工操作。

每批删除大概一分钟,最多50条。

如果遇到微博的Rate limit(提示操作过快),稍等三五分钟再试即可。

@ihipop
ihipop / phpbrew install 5.3.29 practise.md
Last active January 10, 2017 03:00
phpbrew install 5.3.29 practise
apt-get install build-essential autoconf
apt-get install libxml2-dev libevent-dev libgmp-dev libmysqlclient-dev libgd-dev libssl-dev libpng12-dev libjpeg-dev libbz2-dev libicu-dev libmcrypt-dev libreadline-dev libxslt-dev libltdl-dev libpq-dev libcurl4-openssl-dev libvmime-dev
ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
phpbrew install 5.3.29 +default+dbs +gd +fpm +pdo +curl +json +hash +mbstring +fileinfo +soap +session +opcache +imap +readline +iconv

then vim /etc/rc.loal replace #!/bin/sh -e to #!/bin/bash -e in it,then add: