Skip to content

Instantly share code, notes, and snippets.

const date = new Date(Date.UTC(2020, 04, 14, 3, 0, 0));
const options = { month: "long", day: "numeric" };
console.log(new Intl.DateTimeFormat('en-US', options).format(date));
console.log(new Intl.DateTimeFormat('fr-FR', options).format(date));
console.log(new Intl.DateTimeFormat('it-IT', options).format(date));
console.log(new Intl.DateTimeFormat('nl-NL', options).format(date));
@renan
renan / healthy
Created March 21, 2018 21:18
pprof
goroutine 255 [running]:
runtime/pprof.writeGoroutineStacks(0x3006840, 0xc4205d62a0, 0x0, 0xc4202c6ad0)
/root/.gimme/versions/go1.9.4.linux.amd64/src/runtime/pprof/pprof.go:608 +0xa7
runtime/pprof.writeGoroutine(0x3006840, 0xc4205d62a0, 0x2, 0x30, 0x1d60f20)
/root/.gimme/versions/go1.9.4.linux.amd64/src/runtime/pprof/pprof.go:597 +0x44
runtime/pprof.(*Profile).WriteTo(0x2fb2a40, 0x3006840, 0xc4205d62a0, 0x2, 0xc4205d62a0, 0x3088400)
/root/.gimme/versions/go1.9.4.linux.amd64/src/runtime/pprof/pprof.go:310 +0x3ab
net/http/pprof.handler.ServeHTTP(0xc4208401f1, 0x9, 0x3024740, 0xc4205d62a0, 0xc4203ba900)
/root/.gimme/versions/go1.9.4.linux.amd64/src/net/http/pprof/pprof.go:237 +0x1b8
net/http/pprof.Index(0x3024740, 0xc4205d62a0, 0xc4203ba900)
@renan
renan / main.php
Created September 12, 2016 13:59
<?php
if (extension_loaded('xdebug')) {
// Use a empty php.ini and not extra ini files
putenv('PHP_INI_SCAN_DIR=/tmp/composer-php-empty');
passthru('php -c php.ini main.php', $exitCode);
} else {
// Run with the env var
passthru('php sub.php', $exitCode);
@renan
renan / keybase.md
Created April 12, 2016 13:08
keybase.md

Keybase proof

I hereby claim:

  • I am renan on github.
  • I am renan (https://keybase.io/renan) on keybase.
  • I have a public key whose fingerprint is 6F48 05B0 CB8F A824 8C97 90E8 5B11 E317 B3A1 0369

To claim this, I am signing this object:

@renan
renan / code.php
Last active August 27, 2015 08:54
<?php
public function __call($name, $arguments)
{
$callTypeIndex = 3;
if (substr($name, 0, 2) == "is") {
$callTypeIndex = 2;
}
$callType = substr($name, 0, $callTypeIndex);
$propertyName = substr($name, $callTypeIndex);
<?php
class Person
{
public function addPhoneNumber(PhoneNumber $phoneNumber)
{
$this->phoneNumbers[] = $phoneNumber;
}
}
@renan
renan / translator.php
Created October 24, 2014 11:25
Translator
<?php
use \MessageFormatter;
class Translator {
// This should be loading from a file. Eg: .po files (http://en.wikipedia.org/wiki/Gettext)
protected static $messages = [
'pt' => [
'Hello world' => 'Olá mundo',
],
'nl' => [
@renan
renan / packages.sh
Last active August 29, 2015 14:07
Horde Packages with missing required for Composer or PEAR
#!/bin/bash
packages=(
ActiveSync Alarm Argv Auth Browser Cli Compress Core Crypt Data Date Dav
Exception Form Icalendar Image Imap_Client Imsp Itip Kolab_Cli Kolab_FreeBusy
Kolab_Resource Kolab_Storage ListHeaders LoginTasks Mail Mime Mime_Viewer
Model Nls Perms Prefs Push Rpc Service_Facebook Service_Scribd Service_Weather
Share Smtp SyncMl Text_Filter Vfs
)
for package in ${packages[*]}
<?php
namespace App\Model;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
trait ActiveRecordTrait {
protected static $overrideMethodMap = [
'fetch' => 'get',
];
<?php
class OneEntryCacheEngine extends CacheEngine {
protected $_dirty = false;
protected $_data = false;
public function read($key) {
if ($this->_data === false) {
$this->_data = (array)Cache::read($this->_config['cacheKey'], $this->_config['cacheConfig']);
}