Skip to content

Instantly share code, notes, and snippets.

View cr-solutions's full-sized avatar

Ricardo Cescon cr-solutions

View GitHub Profile
####################################################
# WARNING: This is very hacky! Use at your own risk.
#
# This assumes you have all keys in a single DB and
# want to move them all to DB 0. If you have keys
# in more than one DB, the first DB found will be
# rewritten to 0, with all others left alone.
####################################################
import shutil
@mindplay-dk
mindplay-dk / migrator.php
Created June 16, 2012 19:11
Migrate a PHP codebase to use namespaces.
<?php
/**
* Namespace Migration Script
*
* @author Rasmus Schultz <rasmus@mindplay.dk>
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*
* This script will scan through an entire PHP codebase and rewrite the
* scripts, adding a namespace clause based on the directory structure,
@efazati
efazati / Py Flask Skeleton
Last active May 15, 2024 03:39
Python Flask Folders and Files structure
.
├── deploy.py
├── project
│   ├── application.py
│   ├── apps
│   │   ├── articles
│   │   │   ├── forms.py
│   │   │   ├── __init__.py
│   │   │   ├── models.py
│   │   │   └── views.py
@cballou
cballou / medusa.sh
Created December 17, 2013 17:10
Bash script to output recent activity in /var/log/auth.log which may be useful for finding nefarious users.
#!/bin/bash
#####################################################
# To run, simply: chmod +x medusa.sh && ./medusa.sh #
#####################################################
# Successful publickey connections
echo '==== Successful SSH Public Key Connections ===='
CONNECTIONS=`grep "sshd.*Accepted publickey" /var/log/auth.log`
while read -r line; do
@denji
denji / nginx-tuning.md
Last active June 21, 2024 15:08
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@y-gagar1n
y-gagar1n / gist:8469484
Created January 17, 2014 06:57
DateTime format patterns
DateTime.ToString() Patterns
All the patterns:
0 MM/dd/yyyy 08/22/2006
1 dddd, dd MMMM yyyy Tuesday, 22 August 2006
2 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
3 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
4 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
5 dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
@agarzon
agarzon / imgCompress.sh
Last active June 4, 2024 09:41
JPG recursive resize and compress (Linux)
#find . -type f -name '*.png' -exec optipng -o5 -quiet -preserve {} \;
#find . -type f -name '*.jp*' -exec mogrify -compress jpeg -quality 70 {} \;
find . -type f -iname "*.jp*g" | xargs mogrify -resize '1280x1280>'
find . -type f -iname "*.jp*g" | xargs jpegoptim --strip-all --max=90
# With parallel
find . -type f -iname "*.jp*g" -print0 | parallel --progress -0 -j +0 "mogrify -resize 1280x1280\> {}"
find . -type f -iname "*.jp*g" | parallel --progress "jpegoptim --strip-all --max=65 {}"
@hosuaby
hosuaby / web_ui_elements_naming_convention.md
Last active October 3, 2022 06:58
Simple convention for naming GUI elements of Web applications

Simple convention for naming GUI elements of Web applications

Ids or names of elements (primitives or complexes) must be written in Camel Case and must to be as short as possible. All id or name must to start with one of the defined element type prefixes.

Element type prefixes

All element ids or names must use Hungarian notation to incorporate the type of element. Prefixes are used to indicate the semantic type of the element, rather than it's underlining implementation. It means that the element of GUI with button look & feel must prefixed as btn, regardless of how it is implemented, with tag <button> or with tag <a>.
Prefixes are lowercase strings of 2, 3 or 4 characters. Here a complete list of authorised prefixes:

  • btn - the button or a link with a button look & feel
@thanosa75
thanosa75 / find_in_redis.sh
Last active March 4, 2022 05:49
Example of SCAN / COUNT looking for patterns in REDIS
#!/bin/bash
# sample code demonstrating a pattern search with SCAN
# using a COUNT "work intent"
if [ $# -ne 3 ]
then
echo "Find matching a pattern using SCAN "
echo "Usage: $0 <host> <port> <pattern>"
exit 1
@anubhavsinha
anubhavsinha / cwl.sh
Created October 31, 2015 18:46
send events to a stream in a log group in cloudwatch - for elastic search
aws logs put-log-events --log-group-name anubhav-PoC --log-stream-name anubhav-PoC --log-events "[{\"timestamp\":`date +%s%3N`, \"message\": \"Simple ElasticSearch Test\"}]"