Skip to content

Instantly share code, notes, and snippets.

View ghostwriter's full-sized avatar
🐘
while(!succeed=try())

Nathanael Esayeas ghostwriter

🐘
while(!succeed=try())
View GitHub Profile
@ghostwriter
ghostwriter / curl-partial-download.php
Created September 12, 2017 02:02
Using CURL to download partial content from a URL
<?php
/**
*
* Using CURL to download partial content from a URL
*
* @url file URL to download
* @range_start Start range in bytes
* @range_end End range in bytes
*
@ghostwriter
ghostwriter / faucethub_kambas.css
Created July 7, 2018 03:17
custom css for faucethub.io username
background: url(/assets/img/glitter.gif);background-color: #252830;border-color: #1997c6;border-radius: 0.25rem;color: white;font-weight: bold;letter-spacing: 1px;padding: 0.15rem 0.5rem;text-align: center;text-shadow: 1px 1px 8px #4183D7, -1px -1px 8px #4183D7 , 1px -1px 8px #4183D7 , -1px 1px 8px #4183D7 ;text-transform: capitalize;
@ghostwriter
ghostwriter / preg_quote.js
Created February 15, 2019 20:38
preg_quote
function preg_quote(str, delimiter) {
return (str + '').replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&')
}
@ghostwriter
ghostwriter / timeTravel.php
Created April 20, 2019 03:25
a helper function for hijacking Carbon's "now()" inside a callback
<?php
// Helper usage:
// timeTravel(Carbon::parse('one year ago'), function () {...});
function timeTravel($target, $callback) {
Illuminate\Support\Carbon::setTestNow($target);
return tap($callback(), function () {
Illuminate\Support\Carbon::setTestNow();
});
}
// Macro usage:
@ghostwriter
ghostwriter / eloquent_search.php
Created April 20, 2019 03:28
search via eloquent
// Add this to the "boot()" method of your "AppServiceProvider"
<?php
\Illuminate\Database\Eloquent\Builder::macro('search', function ($name, $search) {
return $this->where($name, 'LIKE', $search ? '%'.$search.'%' : '');
});
@ghostwriter
ghostwriter / nathane.keybase.io
Last active January 12, 2020 13:57
Keybase.md
### Keybase proof
I hereby claim:
* I am nathane on github.
* I am nathane (https://keybase.io/nathane) on keybase.
* I have a public key ASDWlm4Hih2sLVgfGKC8TfF-1yh0CI9b2ebzN2rAtrK30Ao
To claim this, I am signing this object:
@ghostwriter
ghostwriter / Schedulable.php
Created April 11, 2020 04:38
Laravel Custom Class/Model Scheduling
<?php
//Don't forget to change the namespace!
namespace App\Traits;
use Cron\CronExpression;
use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ManagesFrequencies;
trait Schedulable{
@ghostwriter
ghostwriter / webpack.mix.js
Created May 5, 2020 01:31
Laravel Mix with multiple Tailwind config and PurgeCSS
const mix = require("laravel-mix");
const tailwindcss = require("tailwindcss");
const rootPath = mix.paths.root.bind(mix.paths);
const tailwindPlugins = function (configFile, paths) {
const pluginList = [tailwindcss(configFile)];
if (mix.inProduction()) {
pluginList.push(
require("@fullhuman/postcss-purgecss")({
@ghostwriter
ghostwriter / cd.yml
Last active May 23, 2020 12:20
Deploy a Laravel app for free with GitHub Actions
name: CD
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
@ghostwriter
ghostwriter / QuantcastChoice.html
Created July 13, 2020 20:40
Obtain and manage consumer consent for GDPR across digital ecosystem with Quantcast Choice. Details here: https://help.quantcast.com/hc/en-us/articles/360047075914-Choice-Universal-Tag-Implementation
<!-- Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) -->
<script type="text/javascript" async="true">
(function() {
var host = window.location.hostname;
var element = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];
var milliseconds = new Date().getTime();
var url = 'https://quantcast.mgr.consensu.org'
.concat('/choice/', 'CUSTOM_ID', '/', host, '/choice.js')
.concat('?timestamp=', milliseconds);