Skip to content

Instantly share code, notes, and snippets.

View eddy85br's full-sized avatar
:atom:

Eduardo L. Francisco eddy85br

:atom:
View GitHub Profile
@lcsbossle
lcsbossle / timed.py
Created June 21, 2021 00:16
Timer decorator for python functions
import time
def timed(func):
def function_timer(*args, **kwargs):
start = time.time()
result = func(*args, **kwargs)
end = time.time()
runtime = (end - start)*1000
message = f"Function [{func.__name__}] executed in {runtime} ms"
@eddy85br
eddy85br / psgrep.sh
Last active February 1, 2018 20:26
Grep Running Processes (psgrep)
#!/bin/bash
################################################################################
## Similar to run: ps aux | grep "RegExp" ##
## Script that receives a list o keywords and search then in "ps axw" command ##
## and returns ps's header and processes that where found with keywords. ##
## Accepts grep options, like '-c' to count number of matched processes. ##
################################################################################
if [ "$#" -eq 0 ]; then
--[[
usage:
local form = multipart:new()
-- set any opts
form:parse()
-- form.fields
]]
local ngx = require("ngx")
local upload = require("resty.upload")
@2called-chaos
2called-chaos / install_nginx_vim.sh
Created March 3, 2013 01:03
enable nginx vim syntax highlighting (on Ubuntu/Debian)
#!/bin/sh
mkdir -p ~/.vim/syntax/
cd ~/.vim/syntax/
wget http://www.vim.org/scripts/download_script.php?src_id=19394
mv download_script.php\?src_id\=19394 nginx.vim
cat > ~/.vim/filetype.vim <<EOF
au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
EOF
@lorn
lorn / starman.sh
Created December 7, 2011 23:23
Starman init.d script
#!/bin/bash
# starman - this script starts and stops the starman daemon
#
# chkconfig: - 85 15
# description: Starman
# processname: starman
# pidfile : /var/run/starman.pid
# www file: /var/www/myapp
@litchfield
litchfield / doubledecode.py
Created October 12, 2011 21:53
Double decode utf8 and cp1252
#!/usr/bin/env python
"""
Ever had a mysqldump of utf8 data stored in latin1 tables, dumped in utf8 and
munged with windows cp1252?
If so this is your friend. Just pipe it through this little baby and spare
yourself hours of unicode hell- it'll take your dirt and spit out clean utf8.
You can also import it and use it in your python code.