This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replaces a where clause in a Builder with another where clause | |
*/ | |
Builder::macro('replaceWhere', function (Builder $passedQuery, \Closure $howToGetValue) { | |
$wheres = $passedQuery->wheres; | |
$query = $passedQuery->cloneWithout([ 'wheres' ]); | |
$bindings = []; | |
foreach ($wheres as &$where) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am gms8994 on github. | |
* I am gms (https://keybase.io/gms) on keybase. | |
* I have a public key ASCHChhicXQkZY3KFtFaXdqMoc-UBiTI3ptvPW5QYZ9r8Qo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am gms8994 on github. | |
* I am gms (https://keybase.io/gms) on keybase. | |
* I have a public key ASCrMIBpO1U0IJmhCiiL_h2IJ_nJNFIo52aVp0Q-J0DX-wo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function instantiate($class) { | |
$model = Yii::$app->modelMapper->instantiateObject(strtolower($class)); | |
if (is_null($model)) { | |
$entityConfigId = substr($this->type, strlen("entity_")); | |
$entityConfig = \epmx\frontend\common\models\EntityConfig::findOne(['id' => $entityConfigId]); | |
$model = new \epmx\frontend\common\models\Entity(['entityConfig' => $entityConfig]); | |
} | |
return $model; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$_vendorModel = $this->instantiate('Vendor')->find()->where(['name' => $vendorModel->name])->one(); | |
if (is_null($_vendorModel)) { | |
$_vendorModel = $this->instantiate('Vendor'); | |
$_vendorModel->name = $vendorModel->name; | |
$success = $_vendorModel->save(); | |
$dirtyAttributes = $itemVendorModel->dirtyAttributes; | |
$dirtyAttributes = array_filter($dirtyAttributes, function($v) { return $v !== ""; }); | |
if (! $success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Models\Program; | |
use Illuminate\Http\Request; | |
use Illuminate\Http\Response; | |
class MainController extends Controller { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Data::Dumper; | |
use DBI; | |
my $dbh = DBI->connect("", "", "", { AutoCommit => 1 }); | |
my $data = `/usr/local/bin/speedtest-cli --simple`; | |
my @lines = split /\n/, $data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# hey! a minimalist CRM for http://todotxt.com/ | |
# | |
# hey tells you one thing you should do regularly, but haven't done lately. | |
# | |
# $ todo.sh lf hey | |
# 1 @phone Mom (+1 234 567 8901) +family | |
# 2 @skype Dad +family | |
# 3 @email mentor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :deploy do | |
desc 'Restart application' | |
task :restart do | |
on roles(:web) do | |
execute "curl -qX POST -H 'authorization: abcd1234' http://www.example.com/_token" | |
end | |
end | |
task :migrate_install do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am gms8994 on github. | |
* I am gms (https://keybase.io/gms) on keybase. | |
* I have a public key whose fingerprint is 304F CBA9 8265 50E1 2FF7 5B07 A90A F690 B812 799C | |
To claim this, I am signing this object: |
NewerOlder