Skip to content

Instantly share code, notes, and snippets.

View macedd's full-sized avatar
🐋
Looking for growth opportunities

Thiago F Macedo macedd

🐋
Looking for growth opportunities
View GitHub Profile
@macedd
macedd / restart-hardware-network.sh
Created May 12, 2017 13:48
Udev Network Services restart
sudo service udev restart
sudo service networking restart
sudo service network-manager restart
@macedd
macedd / gist:5bc3db8b4d22c335d618fd3dd8f74551
Created February 22, 2017 19:09
Apache core dump + backtrace
The following example shows how to use the gcore utility to force a hung process to dump core, and then shows how the gdb utility can be used to retrieve a stack backtrace from the core file:
$ gcore 5649
$ gdb -q /usr/sbin/httpd core.5649
(gdb) backtrace
#0 0x0046e7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x0063b681 in accept () from /lib/tls/libpthread.so.0
#2 0x00b14814 in apr_socket_accept (new=0xbff85740, sock=0x9671538,
@macedd
macedd / ufs.py
Created May 8, 2016 16:50
Brazillian States python object
{
'AC': 'Acre',
'AL': 'Alagoas',
'AP': 'Amapá',
'AM': 'Amazonas',
'BA': 'Bahia',
'CE': 'Ceará',
'DF': 'Distrito Federal',
'ES': 'Espírito Santo',
'GO': 'Goiás',
@macedd
macedd / write-stdin.sh
Created February 1, 2016 12:27
Write to STDIN of running Process
## Alternative 1: write to file descriptor (not usable)
input='testing'
pid=1212
echo $input > /proc/$pid/fd/0
## Alternative 2: Pipe fifo to the app
fifo_file=/tmp/fifo
(function(){
/**
* Module to workout CORS requests with CSRF
*/
angular.module('CorsCSRF')
.config(function($httpProvider)
{
// CSRF Interceptor
$httpProvider.interceptors.push(function($cookies) {
@macedd
macedd / webkit.css
Created January 3, 2016 21:44
Cordova Trigger GPU Rendering
.gpu {
-webkit-transform: translateZ(0);
}
@macedd
macedd / security-check.php
Created December 30, 2015 01:59
Simple Security checks for PHP
<?php
print_r([
exec('woami'), // shell access
get_current_user(), // running user
file_get_contents('/etc/hosts') // open_basedir restriction
]);
@macedd
macedd / TestCase.php
Created November 8, 2015 16:07
Laravel Persist Test Session ID Between Controller Calls
<?php
class TestCase extends Laravel\Lumen\Testing\TestCase
{
/**
* Inject session ID into request, so api can persist on session
*/
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
{
@macedd
macedd / .htaccess
Last active October 19, 2015 12:25
WordPress installed subfolder served in root
# BEGIN WP Admin
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-admin/(.*)$ /site/wp-admin/$1 [QSA,L]
RewriteRule ^wp-(.*)$ /site/wp-$1 [QSA,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
@macedd
macedd / SessionTest.php
Last active October 29, 2021 08:30
Laravel Unit Testing with persistent SessionID
<?php
class ApiTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->session_id = session()->getId();