Skip to content

Instantly share code, notes, and snippets.

View pleonasm's full-sized avatar

Matt Nagi pleonasm

View GitHub Profile
interface Foo {
a: number;
b: number;
c: number;
}
function outputFoo(x: Foo) {
console.log(x);
}
<?php
/**
* Polls an ssh2 stream for data
*
* Reads from an ssh2 stream until $stopText is encountered or $timeout is hit, whichever comes first. Every time
* a newline is encountered, the $lineCallback will be called passing in that line to it (sans the line ending
* characters).
*
* Because you cannot stream_select() on an ssh2 stream and you can't really set the stream to blocking mode (since
* it would always block given an interactive shell), you have to do a read/sleep loop to wait for data from the
<?php
declare(strict_types=1);
namespace RocketFiber\LibRF;
class Net
{
private const IP_MAX = 0xFFFFFFFF;
private const BITS_IN_IPV4 = 32;
<?php
function insertIp(PDO $pdo, $ip, $subnet, $gateway, $vlan, $desc, $recordId)
{
$sql = 'INSERT INTO ipaddresses (ip, subnet, gateway, vlan, descript, record_id) VALUES (?, ?, ?, ?, ?, ?)';
$stmt = $pdo->prepare($sql);
return $stmt->execute([$ip, $subnet, $gateway, $vlan, $desc, $recordId]);
}
<?php
const WHITESPACE = [" ", "\t", "\n"];
function reverse_words($words)
{
$output = '';
$words_len = strlen($words);
$word_buffer = '';
for ($i = 0; $i < $words_len; $i++) {
$character = $words[$i];
@pleonasm
pleonasm / keybase.md
Created October 17, 2014 03:16
keybase.md

Keybase proof

I hereby claim:

  • I am pleonasm on github.
  • I am pleonasm (https://keybase.io/pleonasm) on keybase.
  • I have a public key whose fingerprint is CCCD 8E8B 1FE1 B7B1 A8F6 5BE2 F8CE A407 ADC3 3123

To claim this, I am signing this object:

<?php
$stripe = new Stripe_Service($apiKey);
/** @var Stripe_Charge $charge */
$charge = $stripe->createCharge(array(
'amount' => 400,
'currency' => 'usd',
'card' => '...', // an array, Stripe_Card or token string
'description' => 'Charge for test@example.com',
));
@pleonasm
pleonasm / httpd.conf
Created October 26, 2013 20:27
Minimal httpd.conf file
ServerRoot "/Users/pleonasm/opt"
Listen 80
LoadModule unixd_module modules/mod_unixd.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule dir_module modules/mod_dir.so
<?php
class HumanReadableId
{
const BASE_10 = 10;
const BASE_24 = 24;
const VALID_ENCODED = '@^(?:2|[34679cdfghjkmnpqrtv-z][234679cdfghjkmnpqrtv-z]*)$@i';
const VALID_DECODED = '@^(?:0|[1-9][0-9]*)$@';
private static $mapping = [
@pleonasm
pleonasm / httpd.conf
Created June 24, 2013 01:09
apache 2.4 conf (this assumes it's compiled with mpm_event as the only mpm option)
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so