This file contains hidden or 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
#!/bin/bash | |
token="Get from Github" | |
# Gets a list of the repositories you own (not ones granted through organisation) | |
curl -H "Authorization: token ${token}" https://api.github.com/user/repos?affiliation=owner | grep git_url | sed -r 's/( "git_url": "git:\/\/github.com\/)//' | sed -r 's/.git",//' > url_list.txt | |
# Deletes all the repositories it found on the line before | |
while read r;do curl -XDELETE -H 'Authorization: token ${token}' "https://api.github.com/repos/$r ";done < url_list.txt | |
rm url_list.txt |
This file contains hidden or 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
def get_access_token(self, request): | |
authorization_header = request.META['HTTP_AUTHORIZATION'] | |
bearer, _, token = authorization_header.partition(' ') | |
if bearer != self.AUTH_TYPE_PREFIX: | |
raise ValueError('Invalid token') | |
return token |
This file contains hidden or 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 bash | |
SCRIPT_DEPS="python terraform ssh-keygen ssh-add" | |
function die { | |
echo $1 >&2 | |
exit 1 | |
} | |
function missing_deps { |
This file contains hidden or 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\Domain\Employee; | |
// this introduces a source code dependency | |
use App\Domain\Employee\ScreenOutput; | |
class Employee | |
{ | |
// this violates the dependency inversion principal because we depend on a concretion |
This file contains hidden or 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 | |
$list = [1,2,3,4,5,2,3,4,5]; | |
$total = 0; | |
foreach ($list as $cursor) { | |
// note this is the binary xor operator, not the logical xor | |
$total = $total ^ $cursor; | |
} |
This file contains hidden or 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
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ | |
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ | |
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ | |
&& mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so |
This file contains hidden or 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 | |
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == sha1('version 1.0')) { | |
header('HTTP/1.1 304 Not Modified'); | |
exit; | |
} | |
header('Cache-Control: max-age=604800, public'); | |
header('ETag: ' . sha1('version 1.0') ); | |
?> |
This file contains hidden or 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 | |
class MyException extends Exception {} | |
try { | |
throw new MyException(); | |
} catch (Exception $e) { |
This file contains hidden or 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
'project_ssl' => [ | |
'driver' => 'mysql', | |
'host' => env('DB_HOST', 'localhost'), | |
'database' => env('DB_DATABASE_PROJECT'), | |
'username' => env('DB_USERNAME'), | |
'password' => env('DB_PASSWORD'), | |
'charset' => 'utf8', | |
'collation' => 'utf8_unicode_ci', | |
'prefix' => '', | |
'strict' => false, |
This file contains hidden or 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 | |
/** | |
* This trait applies accessors and mutators to a model attributes if the config setting to encrypt data at rest is on | |
*/ | |
namespace App\Lib\Domain\Models; | |
use Config; | |
use Crypt; |