Skip to content

Instantly share code, notes, and snippets.

View wesleyvicthor's full-sized avatar

wmsan wesleyvicthor

View GitHub Profile
@netojoaobatista
netojoaobatista / 1lr-query.php
Last active December 15, 2015 18:39
Obtendo registros aleatórios de uma base sem utilizar ORDER BY RAND()
<?php
$pdo = new PDO('mysql:host=127.0.0.1;dbname=base', 'user', 'pswd');
$stm = $pdo->query('
SET @count = (SELECT COUNT(*) FROM tabela);
SET @query = CONCAT("SELECT * FROM `tabela` LIMIT 4 OFFSET ", 1 + FLOOR(RAND() * @count));
PREPARE stmt FROM @query;
EXECUTE stmt;
');
<?php
/**
* This is the clock interface. It's really simple, you write it once, use it anywhere.
* Cool extra things you can do:
* - have it return custom value objects
* - separate method for currentDate() without time part
*/
interface Clock
{
@mathieue
mathieue / 6379.conf
Last active April 23, 2022 16:23
redis conf with disk persistance
## Generated by install_server.sh ##
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
@leonderijke
leonderijke / svgfixer.js
Last active May 26, 2023 11:22
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* SVG Fixer
*
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
*
* More info:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
@julz
julz / main.go
Created November 20, 2015 12:39
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@Ocramius
Ocramius / Caddyfile
Last active March 11, 2024 22:14
Example docker + docker-compose + caddy + traefik setup that routes to multiple apps from one exposed HTTP port
:80 {
root /serve
}