Skip to content

Instantly share code, notes, and snippets.

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

Nathanael Esayeas ghostwriter

🐘
while(!succeed=try())
  • 0.0.0.0
View GitHub Profile
@ghostwriter
ghostwriter / pre-push
Created May 11, 2017 02:47
Git pre-push hook for PHPUnit
#!/usr/bin/env php
<?php
echo "Running tests... ";
exec('vendor/bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
// Show full output
echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL;
echo "Cannot push changes untill all tests pass." . PHP_EOL;
exit(1);
}
@ghostwriter
ghostwriter / .htaccess
Created April 18, 2017 03:20
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/

Keybase proof

I hereby claim:

  • I am nathane on github.
  • I am nathane (https://keybase.io/nathane) on keybase.
  • I have a public key ASByU3CgpIKco5WnArzFLSe0IwXhG2U7edyc-Dhe5-bD9go

To claim this, I am signing this object:

@ghostwriter
ghostwriter / config.md
Created May 7, 2016 03:46
This throttle filter config should tag anything more than 30 events in a 60 second period with "chill-out" and we will skip sending them to pagerduty

filter { throttle { before_count => 30 period => 60 add_tag => "chill-out" } }

output { if "chill-out" not in [tags] {

@ghostwriter
ghostwriter / autoLink.php
Created May 2, 2016 20:53
Regex function for adding link tags in PHP.
@ghostwriter
ghostwriter / BladeDirective.php
Created May 2, 2016 20:47
Declare view-specific variables on the fly with a blade directive. Use @var('variable', 'value') to use. Paste the code from this gist into a service provider.
<?php
\Blade::directive('var', function($expression) {
$segments = array_map(function($segment) {
return trim($segment);
}, explode(',', preg_replace("/[\(\)\\\"\']/", '', $expression)));
return '<?php $' . $segments[0] . " = '" . $segments[1] . "' ?>";
});
@ghostwriter
ghostwriter / fabric.curvedText.js
Created April 29, 2016 22:26
Allows you to create curved text - extension to fabric.js
(function (global){
"use strict";
var fabric=global.fabric||(global.fabric={}),
extend=fabric.util.object.extend,
clone=fabric.util.object.clone;
if(fabric.CurvedText){
fabric.warn('fabric.CurvedText is already defined');
@ghostwriter
ghostwriter / animateDecorator.js
Created April 29, 2016 22:17
custom ngAnimate decorator
'use strict';
var forEach = angular.forEach;
angular.module('ngTouchNav')
.config(function($animateProvider) {
$animateProvider.register('', ['$window','$sniffer', '$timeout', function($window, $sniffer, $timeout) {
var noop = angular.noop;
@ghostwriter
ghostwriter / TCP_port_proxy.js
Created February 12, 2016 05:40
A basic TCP port proxy can be used for nearly all TCP traffic.
/*
It was just an idea I had to help mitigate some ddos by having many servers and hiding the real ip of the server using this then we could monitor each one and filter or turn them off as needed etc.
*/
var net = require('net');
function ProxyServer(localport, remoteip, remoteport) {
if (remoteport === undefined)
remoteport = localport;
var server = net.createServer({
allowHalfOpen : false,
@ghostwriter
ghostwriter / cookies.js
Created February 4, 2016 20:15
Simple, no-dependency JavaScript to GET, SET and DELETE cookies
function getCookie(name) {
var cname = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ')
c = c.substring(1);
if (c.indexOf(cname) == 0)
return c.substring(cname.length, c.length);
}