Skip to content

Instantly share code, notes, and snippets.

View nubs's full-sized avatar
🐒
Happy

Spencer Rinehart nubs

🐒
Happy
View GitHub Profile
@nubs
nubs / README.md
Created October 26, 2015 13:58
Example random name generator project

Example Random Name Generator

This is a sample project for the nubs/random-name-generator composer package.

Instructions

First, install the dependencies (I created the composer.json file by running composer require nubs/random-name-generator):

composer install

Keybase proof

I hereby claim:

  • I am nubs on github.
  • I am nubs (https://keybase.io/nubs) on keybase.
  • I have a public key whose fingerprint is 6E15 C8E3 086C E07E B332 C060 C3FC 3474 7FF3 9A9A

To claim this, I am signing this object:

@nubs
nubs / base64.php
Last active December 21, 2015 21:39
<?php
$code = '';
$code = preg_replace('/^<\?/', '', $code);
$specialChars = implode('', array_unique(str_split(preg_replace('#[a-z0-9+/]+#i', '', $code))));
file_put_contents('php://stderr', "Special Characters: " . var_export($specialChars, true) . "\n");
$unusedChars = implode('', array_diff(
str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/+'),
array_unique(array_diff(str_split($code), str_split($specialChars)))
@nubs
nubs / characters-used.md
Last active December 18, 2015 21:48
No alphabetic or non-ascii characters.
  • 91 ([): 210
  • 93 (]): 210

Array to string conversion is the only way to get access to a useful string in PHP. We luck out that the conversion includes an uppercase A, otherwise we may not be able to get uppercase letters without including other characters.

  • 32 ( ): 1
  • 33 (!): 1
  • 44 (,): 1

The only real way of generating these from alphabetic letters is to use binary operators like ^. For example, we could take advantage of the fact that d^H==',', h^H==' ', and i^H=='!'. This should make it possible to remove these three characters adding only the ^ operator.