Skip to content

Instantly share code, notes, and snippets.

🤠
Wranglin' private repo's

Robert K rk

🤠
Wranglin' private repo's
Block or report user

Report or block rk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rk
rk / TransformingStream.php
Created Apr 10, 2019
Buffered Stream to Stream copy with transforms
View TransformingStream.php
<?php
class TransformingStream {
protected $input;
protected $output;
// Chunk size...
protected $chunkSize = 4096;
@rk
rk / keybase.md
Last active Mar 29, 2019
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am rk on github.
  • I am robertkosek (https://keybase.io/robertkosek) on keybase.
  • I have a public key ASCescDdEoT3Hl5loRxfmGzPdeAEC0l99tw_ahzMGXolfgo

To claim this, I am signing this object:

@rk
rk / rename.php
Created Feb 27, 2019
Batch remove prefix from files in current folder
View rename.php
<?php
/**
* rename.php - A Quick and Dirty Prefix Removal Script
*
* This is a quick and dirty prefix removal script. It's meant to be customized quickly and easily, and the
* typical options (the pattern and desired extensions) are defined immediately below.
*
* Writting in 2019 by Robert Kosek <robert[NOSPAM]@woodst.com>
*
@rk
rk / artisan.sh
Created Aug 10, 2018
artisan command that looks in parent directories for where artisan is located.
View artisan.sh
#!/bin/bash
wanted=$(basename $0)
dir=.
while [[ ! -x "$dir/$wanted" ]]; do
if [[ "$dir" -ef "../$dir" ]]; then
echo "$wanted not in the current directory or any of its parents" 1>&2
exit 2
fi
@rk
rk / yitzchok-phptek-2015.md
Last active May 18, 2016
Notes for Yitzchok's talk at php[tek] 2015
View yitzchok-phptek-2015.md

Notes: Everything I Needed to Know, I Learned in Rabbinical School — Yitzchok Willroth — php[tek] 2015

php[architect]

YouTube

  1. Cultivate a mentor for yourself

    phpmentoring.org

    1. Identify
@rk
rk / quartile.sql
Created May 16, 2016
Calculate Quartiles & Median
View quartile.sql
-- Calculates the 1st and 3rd quartiles, and the median, from a given table.
-- This cannot be optimized except by adding an index to the column, as MySQL
-- doesn't support NTILE() natively.
SET @temp_rows = (SELECT GROUP_CONCAT(column ORDER BY column ASC SEPARATOR ',') FROM table WHERE column IS NOT NULL);
SET @temp_count = (SELECT COUNT(column) FROM table WHERE column IS NOT NULL);
SELECT
(SUBSTRING_INDEX(SUBSTRING_INDEX(@temp_rows, ',', ROUND(@temp_count * 0.25 + 1)), ',', -1)) AS 'q1',
(SUBSTRING_INDEX(SUBSTRING_INDEX(@temp_rows, ',', ROUND(@temp_count * 0.5 + 1)), ',', -1)) AS 'median',
@rk
rk / extract test
Created Mar 27, 2012
Tests various methods of "anonymously" calling functions
View extract test
<?php
function print_args() {
foreach(func_get_args() as $value)
echo var_dump($value) . "\n";
}
// This will print "int(2)"
print_args(extract(array('key' => 'value', "bool" => false)));
@rk
rk / dh.go
Created Jan 14, 2012
A failing Diffie-Hellman WIP project in Go. Apparently Go cannot find the "big" package that it comes with?
View dh.go
package main
import (
"fmt"
cr "crypto/rand"
"os"
enc "encoding/ascii85"
"big"
)
@rk
rk / fib.js
Created Oct 3, 2011
Cached fibonacci
View fib.js
var http = require('http');
function fib(n){
if (n < 2) return 1;
else return fib(n-2) + fib(n-1);
}
var cached_fib = (function(){
var cache = {};
return function(n) {
@rk
rk / bcrypt.php
Last active Jan 4, 2018
Simple bcrypt object to wrap crypt() with.
View bcrypt.php
<?php
// Originally by Andrew Moore
// Src: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021
//
// Heavily modified by Robert Kosek, from data at php.net/crypt
class Bcrypt {
private $rounds;
private $prefix;
You can’t perform that action at this time.