Skip to content

Instantly share code, notes, and snippets.

@dopiaza
dopiaza / slackpost
Created September 5, 2013 12:33
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@kajnelissen
kajnelissen / BookingService.php
Last active April 23, 2022 09:15
Constructor Injection in CodeIgniter controllers. Also resolves nested dependencies.
<?php namespace Nelissen\LooseCI\Services;
use Nelissen\LooseCI\Repositories\Room\RoomRepositoryInterface;
use Nelissen\LooseCI\Repositories\Booking\BookingRepositoryInterface;
use Nelissen\LooseCI\Repositories\Booker\BookerRepositoryInterface;
use Nelissen\LooseCI\Models\Room;
use Nelissen\LooseCI\Models\Booker;
use Nelissen\LooseCI\Exceptions\BookingExceedsRoomCapacityException;
/**
@danharper
danharper / x.md
Created January 27, 2015 08:15
Symfony UploadedFile methods with FileBag notes

Three file inputs, last being "multiple". Let's say we upload a file on each, and three on the multiple input (upload3).

<input type="file" name="upload1">
<input type="file" name="upload2">
<input type="file" name="upload3[]" multiple> <!-- note the [] on name to indicate array -->

Getting files off Request:

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@geerteltink
geerteltink / SymfonyCustomFormTypeWithValidation.php
Last active February 13, 2022 21:25
Symfony 3 forms validation constraints without an entity
<?php
// ...
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
@benjaminrau
benjaminrau / Emma_MediaBundle_EventListener_SerializeListener.php
Last active June 7, 2021 07:53
File Upload (JSON) and store with Sonata Media Bundle (based on ApiPlatform 2.0, Symfony 3.1)
<?php
namespace Emma\MediaBundle\EventListener;
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface;
use Emma\MediaBundle\Entity\MediaElement;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\Serializer\SerializerInterface;

First suggestion:

src/
  <pkgname>.nim
tests/
docs/
<pkgname>.nimble # with srcDir = "src"

library with single module

@ganapativs
ganapativs / iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup.md
Last active July 16, 2024 14:36
iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup
@aliboy08
aliboy08 / JWT.php
Created August 27, 2019 23:41
Generate JWT Token using Firebase JWT php library
<?php
/**
* JSON Web Token implementation, based on this spec:
* https://tools.ietf.org/html/rfc7519
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
* @author Neuman Vong <neuman@twilio.com>