Skip to content

Instantly share code, notes, and snippets.

View macghriogair's full-sized avatar

Patrick macghriogair

  • Berlin
View GitHub Profile
@macghriogair
macghriogair / CacheAwareGeocoder.php
Last active August 31, 2018 11:12
[Geocoder] #laravel
<?php
/**
* @date 2017-09-26
* @file CacheAwareGeocoder.php
* @author Patrick Mac Gregor <[email protected]>
*/
namespace Dreipc\Geocoder;
@macghriogair
macghriogair / script.js
Last active August 31, 2018 15:06
Tampermonkey Remove Redmine Prio Styles #tampermonkey
// ==UserScript==
// @name Redmine hide useless colors
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author pmg
// @include https://redmine.3pc.de*
// @grant none
// ==/UserScript==
@macghriogair
macghriogair / MockGuzzle.php
Last active August 31, 2018 10:56
Mocking Guzzle #tests #guzzle
<?php
namespace Tests;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Response;
@macghriogair
macghriogair / array-includes.js
Last active August 31, 2018 15:08
[polyfill array includes] #polyfill
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
if (!Array.prototype.includes) {
Object.defineProperty(Array.prototype, 'includes', {
value: function(searchElement, fromIndex) {
if (this == null) {
throw new TypeError('"this" is null or not defined')
}
// 1. Let O be ? ToObject(this value).
@macghriogair
macghriogair / object-assign.js
Last active August 31, 2018 15:09
[polyfill object assign] #polyfill
if (typeof Object.assign !== 'function') {
Object.assign = function(target) {
'use strict'
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object')
}
target = Object(target)
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index]
@macghriogair
macghriogair / acceptance.yml
Last active August 31, 2018 12:42
[PhantomJs with Codeception and docker compose] #phantomjs #tests #docker
actor: AcceptanceTester
modules:
enabled:
- \Helper\Acceptance
- WebDriver:
host: phantomjs
#host: localhost
port: 8910
#port: 4444
#url: 'http://localhost:8080'
@macghriogair
macghriogair / gensupervisors.py
Created August 31, 2018 12:46
[Supervisord Config Generator] #supervisord
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Patrick Mac Gregor
# @Date: 2018-05-24
# @Last Modified by: Patrick Mac Gregor
# @Last Modified time: 2018-05-24
import sys
from jinja2 import Template
from inspect import cleandoc
@macghriogair
macghriogair / deploy
Created August 31, 2018 14:53
[Deploy LXC + Git] deploy revision via remote script execution #lxc #deploy #git #semaphore #ci
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no <USER>@<HOST> lxc exec <CONTAINER_NAME> -- sudo -u www-data -I <PATH-TO-REMOTE-DEPLOY-SH> $REVISION
@macghriogair
macghriogair / text
Created August 31, 2018 14:56
[LXC Adding remote] #lxc
# First you need to make sure that “foo” is listening to the network and has a password set, so get a remote shell on it and run:
lxc config set core.https_address [::]:8443
lxc config set core.trust_password something-secure
# Now on your local LXD, we just need to make it visible to the network so we can transfer containers and images from it:
lxc config set core.https_address [::]:8443
# Now that the daemon configuration is done on both ends, you can add “foo” to your local client with:
@macghriogair
macghriogair / filter.js
Last active September 1, 2018 01:50
[Array map filter boolean] #array #filter #boolean
myArray
.map(item => {
// ...
})
// Get rid of bad values
.filter(Boolean);