Skip to content

Instantly share code, notes, and snippets.

View brunocassol's full-sized avatar

Bruno Cassol brunocassol

View GitHub Profile
@mattattui
mattattui / hash_pbkdf2.php
Last active May 17, 2016 09:23
PHP PBKDF2 implementation
<?php
/* PHP PBKDF2 implementation
*
* PBKDF2 is a key derivation function defined in RFC2898. It's used to
* generate longer and more secure passwords from short, human-entered
* passwords. The number of rounds can be increased to keep ahead of
* improvements in CPU/GPU performance.
*
* You should use a different salt for each password (it's safe to store it
<?php
class _╯°□°╯︵┻━┻ extends \Exception {}
function _╯°□°╯︵┻━┻($message) {
throw new _╯°□°╯︵┻━┻($message);
}
_╯°□°╯︵┻━┻("Flip Table");
@peterhellberg
peterhellberg / tunnel-plasma.go
Last active April 2, 2019 21:08
Tunnel effects in Go
package main
import (
"image"
"math"
"time"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"github.com/peterhellberg/plasma"
@ziadoz
ziadoz / scrape.php
Created August 13, 2012 21:54
Scraping Google using PHP and Goutte:
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):
import json
import datetime
import pytz
from random import randint
import logging
import time
import redis
main_prefix = "bqueues:"
@grahamking
grahamking / slicemap_test.go
Created June 30, 2015 04:11
Benchmark comparing map access vs slice search
package main
import (
"math/rand"
"testing"
"time"
)
const (
numItems = 100 // change this to see how number of items affects speed
@dhrrgn
dhrrgn / RedisSession.php
Last active February 15, 2022 19:54
PHP 5.4 Redis Session Handler
<?php
use Predis\Client;
class RedisSession implements SessionHandlerInterface {
private $redis;
private $keyPrefix;
private $maxLifetime;
/**
@peterhellberg
peterhellberg / graceful.go
Last active August 20, 2023 08:49
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@chadrien
chadrien / README.md
Last active September 1, 2023 12:43
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@bryanbarnard
bryanbarnard / SimpleHttpClient.cs
Created December 23, 2013 19:15
Simple C# .NET 4.5 HTTPClient Request Using Basic Auth and Proxy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
namespace HTTP_Test