Skip to content

Instantly share code, notes, and snippets.

View rk's full-sized avatar
🤠
Wranglin' private repo's

Robert K rk

🤠
Wranglin' private repo's
View GitHub Profile
@rk
rk / breaks.html
Last active October 21, 2021 21:00
Million Patch Problem
<!DOCTYPE html>
<body>
<div id="app"></div>
<script type="module">
import {
m,
patch,
/* or any other exports you want to access */
} from 'https://unpkg.com/million?module';
@rk
rk / TransformingStream.php
Created April 10, 2019 19:06
Buffered Stream to Stream copy with transforms
<?php
class TransformingStream {
protected $input;
protected $output;
// Chunk size...
protected $chunkSize = 4096;
@rk
rk / keybase.md
Last active March 29, 2019 21:42
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 February 27, 2019 18:10
Batch remove prefix from files in current folder
<?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 August 10, 2018 13:18
artisan command that looks in parent directories for where artisan is located.
#!/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 20:00
Notes for Yitzchok's talk at php[tek] 2015

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

  2. Identify

@rk
rk / quartile.sql
Created May 16, 2016 21:01
Calculate Quartiles & Median
-- 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 March 27, 2012 15:57
Tests various methods of "anonymously" calling functions
<?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 January 14, 2012 15:51
A failing Diffie-Hellman WIP project in Go. Apparently Go cannot find the "big" package that it comes with?
package main
import (
"fmt"
cr "crypto/rand"
"os"
enc "encoding/ascii85"
"big"
)
@rk
rk / fib.js
Created October 3, 2011 13:07
Cached fibonacci
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) {