Skip to content

Instantly share code, notes, and snippets.

View tobyjoiner's full-sized avatar

Toby Joiner tobyjoiner

  • Joiner Software
  • Idaho
View GitHub Profile
public function getSalesmanTerritory()
{
return
$this->salesman->fname .
' ' .
$this->salesman->lname .
' ' .
$this->territory->name;
}
@tobyjoiner
tobyjoiner / method_benchmark.php
Last active October 7, 2020 20:15
Benchmark a method
function runBenchMark($method, $runs){
$time_start = microtime(true);
for( $i=0; $i <= $runs; $i++){
$method();
}
$time_end = microtime(true);
return (float)($time_end - $time_start);
}
function benchMark($method1, $method2, $runs){
@tobyjoiner
tobyjoiner / get_class_methods_search.php
Created October 7, 2020 20:13
Search a class object for the methods available.
class Query
{
private $haystack;
private $matches;
public function handle($class, $find='')
{
$this->getHaystack($class);
@section('js')
<script>
window.category = '{{ $category }}';
</script>
@endsection
@tobyjoiner
tobyjoiner / rename.txt
Created July 17, 2020 13:34
Copy file from name to name.backup
sudo cp /etc/samba/smb.conf{,.backup}
@tobyjoiner
tobyjoiner / sp.py
Last active October 7, 2020 20:20
This will switch projects using Laravel Valet to only load the current project and an api if needed.
#!/usr/local/bin/python3
import os
class ActiveSite:
def __init__(self, dbg=False):
self.debug = dbg
self.apiLocation = '<oldapilocation>'
self.newApiLocation = '<newapilocation>'
namespace :db do
desc "load data from csv"
task :load_csv_data => :environment do
require 'fastercsv'
FasterCSV.foreach("importdata/tarife.csv", :headers => true, :col_sep => ',') do |row|
Anbieter.find_or_create_by_name(
:name => row['Anbieter_Name']
:hotline => row['Hotline'],
:email => row['Email']