Skip to content

Instantly share code, notes, and snippets.

View rahenrique's full-sized avatar
🐺

Rafael Henrique rahenrique

🐺
View GitHub Profile
@jakebellacera
jakebellacera / ICS.php
Last active March 11, 2025 21:41
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@Thinkscape
Thinkscape / mysql-backup-all.sh
Created March 27, 2012 11:38
Backup all mysql databases to separate archives, each table in separate file.
#!/bin/bash
#
# Backup all databases to separate archives.
# 1. Each table is dumped into separate *.sql file.
# 2. Each view is dumped into separate file with DEFINER=CURRENT_USER.
# 3. All routines are dumped into routines-dbname.sql,
# 4. All files are added to archive dbname.7z, compressed with 7-zip, max compression.
#
# Usage: mysqlback.sh /output/directory
#
@amitsaha
amitsaha / ls.rst
Last active June 6, 2024 04:01
How does `ls` work?

How does ls work?

I wanted to be really able to explain to a fair amount of detail how does the program :command:`ls` actually work right from the moment you type the command name and hit ENTER. What goes on in user space and and in kernel space? This is my attempt and what I have learned so far on Linux (Fedora 19, 3.x kernel).

How does the shell find the location of 'ls' ?

@yuval-a
yuval-a / js-micro.js
Last active November 28, 2024 08:13
Javascript micro-optimizations
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax.
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
@igniteflow
igniteflow / mock-django-cache.py
Created July 6, 2015 12:57
Mock Django's cache in unit tests
"""
myapp/mymodule.py:
from django.core.cache import cache
def set_cache():
cache.set('foo', 'bar')
def get_cache():
return cache.get('foo')
@ecdundar
ecdundar / copymysql.sh
Last active September 12, 2024 16:18
Copy MySQL Database One Server (Remote) To Another (Local) Server
#!/bin/bash
# copymysql.sh
# GENERATED WITH USING ARTUR BODERA'S SCRIPT
# Source script at: https://gist.github.com/2215200
MYSQLDUMP="/usr/bin/mysqldump"
MYSQL="/usr/bin/mysql"
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@im4aLL
im4aLL / php-event-listener-example.php
Last active August 18, 2024 18:18
PHP event listener simple example
<?php
// Used in https://github.com/im4aLL/roolith-event
class Event {
private static $events = [];
public static function listen($name, $callback) {
self::$events[$name][] = $callback;
}
@lapointexavier
lapointexavier / read_vcrpy_binary_body.py
Last active November 24, 2023 12:55
Snippet to read a vcr cassette binary body
import json
import gzip
import base64
import StringIO
from vcr.serialize import deserialize
from vcr.serializers import yamlserializer
path = '../cassettes/api-InstagramAPITestCase-test_media.yml'
@noelboss
noelboss / git-deployment.md
Last active March 2, 2025 15:09
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.