Skip to content

Instantly share code, notes, and snippets.

View Seldaek's full-sized avatar
😀
😀

Jordi Boggiano Seldaek

😀
😀
View GitHub Profile
@Seldaek
Seldaek / sha1hmac.js
Created February 3, 2012 13:37
SHA1 + HMAC in JS
var Crypto = {};
Crypto.sha1_hmac = function (msg, key) {
"use strict";
var oKeyPad, iKeyPad, iPadRes, bytes, i, len;
if (key.length > 64) {
// keys longer than blocksize are shortened
key = Crypto.sha1(key, true);
}
curl -XPOST -v https://packagist.org/api/github --data 'payload={"repository":{"url":"https://github.com/FOO/BAR"}}&apiToken=TOKEN&username=USERNAME'
@Seldaek
Seldaek / composer.json
Created April 11, 2016 15:36
Self-signed SSL composer repo
{
"repositories": [
{
"type": "composer",
"url": "https://toran.example.org",
"options": {
"ssl": {
"cafile": "/path/to/file/with/your/cert.pem"
}
}
@Seldaek
Seldaek / Authenticator.php
Created November 20, 2012 11:19
Simple Symfony Auth example
<?php
namespace Acme\DemoBundle\Security;
use Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\HttpFoundation\Request;
@Seldaek
Seldaek / ext-requires.txt
Last active February 15, 2020 18:52
PHP Extension Requirements on Packagist.org
Taken from packagist.org
Packages with a master branch update since June 1st 2018: 98977
Of those, package having requires on PHP extensions: 11676 (11.79%)
As only ~12% of packages declare their extension requirements,
and even then it might not be a complete list, take all this with
a big grain of salt, it is informative but definitely not a
complete picture of the most used extensions.
@Seldaek
Seldaek / potential-squatters.txt
Created June 29, 2016 19:22
Potential Typo-squatters
adam-paterson adampaterson => oauth2-stripe
components component => foundation
#eveseat eve-seat => seat
#frozzare frozzere => wp-admin-menu-tabs
guzzlehttp puzzlehttp => streams
gwis gws => php-valueobjects
ite ice => form-bundle
kcs ucs => utils
laravel larvel => framework
mindy hindy => application, base, cache, console, controller, di, event, exception, helper, http, locale, logger, middleware, orm, query, router, security, session, tests, utils, validation
@Seldaek
Seldaek / rant.log
Created April 17, 2015 20:54
freenode/#composer rant
03:54 -!- THEBEEFSTEAK has joined #composer
03:54 <THEBEEFSTEAK> hey guyys
03:54 <THEBEEFSTEAK> RobLoach
03:55 <THEBEEFSTEAK> sandvige
03:55 <THEBEEFSTEAK> scottrigby
03:55 <THEBEEFSTEAK> skoop
03:55 <THEBEEFSTEAK> Spea
03:55 <THEBEEFSTEAK> tonton
03:55 <THEBEEFSTEAK> tystr:
03:55 <THEBEEFSTEAK> s+e:

Keybase proof

I hereby claim:

  • I am seldaek on github.
  • I am seldaek (https://keybase.io/seldaek) on keybase.
  • I have a public key whose fingerprint is 96DC 30A1 E352 6046 F9A1 31E9 C435 9456 C838 78B3

To claim this, I am signing this object:

@Seldaek
Seldaek / bench.php
Created December 8, 2015 10:33
strtr vs str_replace benchmark
<?php
$jobs = array(
'old/strtr' => function($args) {
$classes = [];
foreach ($args as $class) {
$classes[] = strtr($class, '\\', DIRECTORY_SEPARATOR);
}
return $classes;
},
@Seldaek
Seldaek / foo.php
Created September 30, 2016 08:23
Case-insensitive Classmap
// in POST_AUTOLOAD_DUMP
$map = include('autoload_classmap.php');
// TODO lowercase all keys
file_put_contents('autoload_classmap.php', '<?php return '.var_export($map, 1));
// the above should be done without include ideally to keep the classmap using relative paths,
// but if you don't move the project files around then this is fine.