Skip to content

Instantly share code, notes, and snippets.

Brady Wetherington uberbrady

Block or report user

Report or block uberbrady

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
View indenter3.php
$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;
View indenter2.php
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.'--'));
}
View gist:72ba93aea1bacd5007ef107a4b944078
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 Sep 29, 2018
Experimental filesystems.php which should get the best of all worlds, maybe?
View filesystems.php
<?php
$config = [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
View brady_million.rb
#!/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
View bryan_million.rb
#!/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
View ruby_sucks.rb
#!/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")
View million.php
<?php
$arr=[];
for($i=0;$i<1000000;$i++) {
$arr[]="poopiedoop@fart.nuckle";
}
print count($arr);
View million.rb
#!/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 Dec 21, 2016
Using 'co' with Thunks instead of Promises
View co_thunk.js
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)
}
You can’t perform that action at this time.