Skip to content

Instantly share code, notes, and snippets.

View uberbrady's full-sized avatar

Brady Wetherington uberbrady

View GitHub Profile
$locations_with_children=[];
foreach($locations as $location) {
$locations_with_children[$location->parent_id] = true;
}
public static function indenter($locations, $locations_with_children, $parent_id = null, $prefix = '') {
$results = Array();
foreach($locations as $location) {
$locations_with_children[$location->parent_id] = true;
function indenter($locations, $parent_id = null, $prefix = '') {
$results = Array();
foreach($locations as $location) {
if($location->parent_id == $parent_id) {
//append this parent node first,
$location->use_text = $prefix.' '.$location->name
$results[] = $location;
//now append the children.
$results = array_merge($results,indenter($locations,$location->id,$prefix.'--'));
}
function indenter($locations, $parent_id = null, $prefix = '') {
$results = Array();
foreach($locations as $location) {
if($location->parent_id == $parent_id) {
//append this parent node first,
$results[] = [
'id' => $location->id,
'text' => $prefix.' '.$location->name,
'image' => $location->image
@uberbrady
uberbrady / filesystems.php
Created September 29, 2018 03:13
Experimental filesystems.php which should get the best of all worlds, maybe?
<?php
$config = [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
#!/usr/bin/env ruby
a=[]
1_000_000.times do |what|
a.concat ["froopty@blorp.norb#{what}"]
p "ten thousand: #{what}" if what % 10_000 == 0
end
p "A length is: #{a.count}"
p a
#!/usr/bin/env ruby
a=[]
1_000_000.times do |what|
a<< "froopty@blorp.norb#{what}"
p "ten thousand: #{what}" if what % 10_000 == 0
end
p "A length is: #{a.count}"
p a
#!/usr/bin/env ruby
# a=[]
require 'tempfile'
f=Tempfile.open
1_000_000.times do |what|
# a+=["froopty@blorp.norb"]
f.write("froopty@blorp.norb#{what}\n")
<?php
$arr=[];
for($i=0;$i<1000000;$i++) {
$arr[]="poopiedoop@fart.nuckle";
}
print count($arr);
#!/usr/bin/env ruby
a=[]
1_000_000.times do |what|
a+=["froopty@blorp.norb"]
end
p "A length is: #{a.count}"
@uberbrady
uberbrady / co_thunk.js
Created December 21, 2016 23:24
Using 'co' with Thunks instead of Promises
const co = require('co')
function gen () {
console.warn('Beginning wait for gen')
return (callback) => {
setTimeout( () => {
console.warn("waiting finished for 'gen'")
callback(null,7)
},2000)
}