Skip to content

Instantly share code, notes, and snippets.

View slow-is-fast's full-sized avatar

slow-is-fast slow-is-fast

View GitHub Profile
@slow-is-fast
slow-is-fast / agnoster.md
Created July 9, 2016 07:38 — forked from petres/agnoster.md
Zsh (oh-my-zsh) Agnoster Theme Adaption for SVN

Agnoster Adaption

The SVN plugin of the oh-my-zsh ZSH distribution is not working with the agnoster theme, because it's simple not used in the prompt of the theme. Here two adaption of the theme file (themes/agnoster.zsh-theme) are listed, which are showing a nice prompt when you are in a SVN working directory.

  • Using the SVN plugin (with dirty symbol)
prompt_svn() {
  local rev branch
  if in_svn; then
@slow-is-fast
slow-is-fast / counting_nginx.py
Created July 15, 2016 14:15 — forked from orangle/counting_nginx.py
使用nginx post_action参数来统计文件下载情况,从而统计用户下载文件完整性
#!/usr/bin/python
#-*- coding:utf-8 -*-
############################
#File Name: counting_file.py
#Author: orangleliu
#Mail: orangleliu@gmail.com
#Created Time: 2015-03-11 16:41:05
#License: MIT
############################
'''
@slow-is-fast
slow-is-fast / nginxvarcore.md
Created July 16, 2016 03:27 — forked from esfand/nginxvarcore.md
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line
@slow-is-fast
slow-is-fast / validation.php
Created October 16, 2016 08:59 — forked from chareice/validation.php
Localization Validation Message For Chineses With Laravel 5
<?php
use Symfony\Component\Yaml\Yaml;
return Yaml::parse(file_get_contents(base_path().'/resources/lang/zh_cn/validation.yml'));
@slow-is-fast
slow-is-fast / pg-running-queries.sql
Created November 22, 2017 08:40 — forked from JoshuaGross/pg-running-queries.sql
List running queries in PostGres
select * from pg_stat_activity;
@slow-is-fast
slow-is-fast / redis_key_sizes.sh
Last active December 20, 2017 02:46 — forked from epicserve/redis_key_sizes.sh
A simple script to print the size of all your Redis keys. #redis
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
@slow-is-fast
slow-is-fast / MultiPartFromStrings.php
Created August 16, 2018 09:58 — forked from iansltx/MultiPartFromStrings.php
Multipart file uploads in PHP from strings
<?php
/**
* PHP's curl extension won't let you pass in strings as multipart file upload bodies; you
* have to direct it at an existing file (either with deprecated @ syntax or the CURLFile
* type). You can use php://temp to get around this for one file, but if you want to upload
* multiple files then you've got a bit more work.
*
* This function manually constructs the multipart request body from strings and injects it
* into the supplied curl handle, with no need to touch the file system.
@slow-is-fast
slow-is-fast / __upload_file.md
Created August 16, 2018 09:58 — forked from maxivak/__upload_file.md
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");;
function removeEmoji($text)
{
$cleanText = "";
// Match Emoticons
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
$cleanText = preg_replace($regexEmoticons, '', $text);
// Match Miscellaneous Symbols and Pictographs
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
@slow-is-fast
slow-is-fast / gist:b3d6fba9218d36e318d116836035bb5f
Created April 26, 2019 00:48 — forked from andphe/gist:3232343
Export your links from Safari reading list
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'