Skip to content

Instantly share code, notes, and snippets.

@zyphlar
zyphlar / create_elastic_cloud_watcher.sh
Last active December 15, 2017 02:34
Creates a Slack-compatible watcher for elastic.co cluster size
curl -u admin -p -XPUT 'https://your_elasticsearch_url:9243/_watcher/watch/cluster_size_watch' -d '{
"trigger" : {
"schedule" : { "interval" : "60s" }
},
"input" : {
"http" : {
"request" : {
"host" : "your_elasticsearch_url",
"port" : 9243,
"scheme" : "https",
@zyphlar
zyphlar / pdo.php
Created March 11, 2016 00:21
pdo example
<?php
//..
$foo = "foofoo";
$bar = "barbar";
$conn = new PDO('mysql:host=yourserverip;dbname=yourdatabasename', 'username', 'password');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@zyphlar
zyphlar / symfony-post-controller-hook.php
Created February 25, 2016 19:22
after-controller-response hooks in Symfony2
<?php
public function myPostControllerFunction($someObject) {
$dispatcher = $this->get('event_dispatcher');
$logger = $this->get('logger');
$dispatcher->addListener('kernel.terminate', function ($event) use ($logger, $someObject) {
$logger->warning('This log entry was generated after Kernel Terminate and was passed an object of class: '.get_class($someObject));
});
}
<?php
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\AbstractType;
class MyFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
@zyphlar
zyphlar / refile_bootstrap_progress_bars.1.js
Last active February 10, 2016 17:44
Adding Bootstrap Progress Bars to Refile with Multiple File Upload Enabled
// refile upload progress
var uploadsSuccessful = 0;
var uploadsFailed = 0;
var uploadsCompleted = 0;
var uploadsTotal = 0;
var progressBarParent = null;
$(document).on("upload:start", "form", function(e) {
$(this).find("input[type=submit]").attr("disabled", true);
@zyphlar
zyphlar / pr-template.md
Created January 5, 2016 19:14
Pull Request Template for Git-Splainin

What does this PR do?

How should this be manually tested?

What are the relevant story, task, or ticket links?

What are the deployment instructions (if any?)

@zyphlar
zyphlar / REFILE-WATERMARK.md
Last active May 18, 2019 19:48
Adds Watermarking ability to Refile

Usage:

#fill_watermark_text(img, width, height, text, gravity = "Center")
attachment_url(object, :attachment, :fill_watermark_text, 800, 600, "My Watermark")
@zyphlar
zyphlar / gist:b980f22b9b2c47935628
Last active December 9, 2021 17:46
Talking about makerspace management and hackerspaces
11:31 AM <LesaraRose> Sorry. I have a lot of questions lol
11:33 AM <TheWill> hardest: inspiring volunteers. work: being everybody's surrogate parent because they were ~20yo and antisocial and didn't know how to avoid generating a storm of drama everywhere they go
11:34 AM <TheWill> the idea of "everybody contributes towards the common good" is great until you're dealing with people who can't resolve the "who washes the dishes" conflict with their roommate
11:35 AM <TheWill> in other words a balance of demographics is vastly superior even if less comfortable
11:36 AM <TheWill> having a paid community manager is in my opinion the most effective way to reduce drama
11:36 AM <TheWill> and burnout
11:40 AM <myself> Hardest: Getting our external image to reflect the diversity of stuff actually happening in the space. Our technical people get more attention than our artistic people, so it takes a lot of work to bring in more artistic people. Yet, when we take both technical and artistic projects to show off at an e
<?php
namespace Acme\YourBundle\Listener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Bundle\TwigBundle\TwigEngine;
@zyphlar
zyphlar / Preferences.sublime-settings
Last active September 2, 2015 17:05
Binary and Folder exclude patterns for Symfony projects (and in general)
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",