Skip to content

Instantly share code, notes, and snippets.

View phroggyy's full-sized avatar
🔥
Building the world's best incident management platform

Leo Sjöberg phroggyy

🔥
Building the world's best incident management platform
View GitHub Profile
@phroggyy
phroggyy / directive.php
Created August 5, 2015 22:17
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.
\Blade::directive('var', function($expression) {
$segments = array_map(function($segment) {
return trim($segment);
}, explode(',', preg_replace("/[\(\)\\\"\']/", '', $expression)));
return '<?php $' . $segments[0] . " = '" . $segments[1] . "' ?>";
});
var Vue = require('vue');
var validator = require('vue-validator');
Vue.use(validator);
// Change this when compiling for production
Vue.config.debug = true;
Vue.config.silent = false;
// Register some directives and filters
<?php
array_walk($x=file('i'),function(&$g) {
$g=explode('x', $g);
sort($g, SORT_NUMERIC);
});
$p = $r = 0;
foreach ($x as $g) {
$p += 2*($g[0]*$g[1] + $g[0]*$g[2] + $g[1]*$g[2]) + $g[0]*$g[1];
$r += 2*($g[0]+$g[1])+array_product($g);
<?php $p=$r=0;foreach(file('i')as$g){$g=explode('x',$g);sort($g,1);$z=$g[0]*$g[1];$y=$g[0]+$g[1];$p+=2*$g[2]*$y+3*$z;$r+=$y*2+$z*$g[2];}echo"$p,$r";
<?php
$input = str_split(file('i')[0]);
$map = [
'^' => [1,0],
'>' => [0,1],
'v' => [-1,0],
'<' => [0,-1],
];
<?php
$f = str_split(file('i')[0]);
$map = [
'^' => [1,0],
'>' => [0,1],
'v' => [-1,0],
'<' => [0, -1],
];
@phroggyy
phroggyy / nginx.conf
Last active January 27, 2016 13:45
redirect all http requests and www.* requests to https://host.name/ Credit to @jaw-sh for the script
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
@phroggyy
phroggyy / ViewServiceProvider.php
Created April 28, 2016 13:40
A tiny service provider to allow you to register views by modules
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class ViewServiceProvider extends ServiceProvider
{
public function register()
{
@phroggyy
phroggyy / bsocial.ex
Last active May 7, 2016 19:53
A super basic WS server
defmodule Bsocial do
use Application
def start(_type, _args) do
import Supervisor.Spec
children = [
supervisor(Task.Supervisor, [[name: Bsocial.ConnectionsSupervisor]]),
worker(Task, [Bsocial.Server, :start, [4000]])
]
@phroggyy
phroggyy / test-webhook.sh
Created May 3, 2016 10:44
SparkPost test relay webhook
curl -X POST -H "X-MessageSystems-Webhook-Token: TOKEN_IF_YOU_NEED_IT -H "Cache-Control: no-cache" -d '[
{
"msys": {
"relay_message": {
"rcpt_to": "[email protected]",
"friendly_from": "[email protected]",
"customer_id": "1521",
"content": {
"text": "Simple Test\r\n\r\n",
"subject": "Simple Test Please Ignore This...",