Skip to content

Instantly share code, notes, and snippets.

View johnpancoast's full-sized avatar

John Pancoast johnpancoast

  • California, U.S.
View GitHub Profile
@johnpancoast
johnpancoast / CreateJwtKeysCommand.php
Last active March 9, 2017 04:57
Command to automatically create JWT keys required by LexikJWTAuthenticationBundle
<?php
namespace My\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;
@johnpancoast
johnpancoast / TokenController.php
Last active August 20, 2019 08:22
Example of how to use FOS OAuth Server Bundle without a client secret
<?php
/**
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
@johnpancoast
johnpancoast / vimdiff.md
Created April 21, 2016 21:37 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@johnpancoast
johnpancoast / README.md
Created March 30, 2016 05:29 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@johnpancoast
johnpancoast / watchfile.sh
Created January 6, 2016 01:04 — forked from swarminglogic/watchfile.sh
watchfile - monitor file(s) and execute a command when files are changed
#!/bin/bash
version=1.0.1
versionDate="2014-02-14"
function showHelp() {
echo "watchfile - monitor file(s)/command and perform action when changed
Possible ways of usage
----------------------------------------
@johnpancoast
johnpancoast / mongo-doc-prob.php
Last active August 29, 2015 14:15
Embedded Mongo Doc Prob
/**
* @ODM\MappedSuperclass
*/
class BaseFoo
{
/**
* @var string
* @ODM\String
* @Assert\Type(type = "string")
* @Assert\NotBlank
@johnpancoast
johnpancoast / gist:8564738b079b59f5c45d
Last active August 29, 2015 14:12
PhpStorm setup notes
- Changed fonts to be sys font. Appearance and Behavior > Appearance > Override default fonts by (not recommended) > then changing to Lucida Grande [12]).
- Turned on line numbers (Pref > Editor > General > Appearance)
- Installed Ideavim plugin (browse repositories)
- Installed Symfony 2 plugin (browse repositories)
- Installed Color IDE plugin (browse repositories)
- Setup "next splitter" and "previous splitter" shortcuts to be ctrl wl and ctrl wh to mimic VIMs movements between split windows.
- Setup "move tab to opposite group" shortcut to be ctrl <space>. Only way I saw to move current tab to another split pane via keys.
- Symlink ~/.vimrc < ~/.ideavimrc
- Turned off audible bells. Put following in ~/.ideavimrc
set visualbell
@johnpancoast
johnpancoast / framework-example.php
Last active December 21, 2015 18:09
Framework Example
<?php
// handle a request, generate a response
interface RequestHandlerInterface
{
public function setInputHandler(InputHandlerInterface $inputHandler);
public function getInputHandler();
public function setOutputHandler(OutputHandlerInterface $outputHandler);
public function getOutputHandler();
<?php
namespace MyApplication\Controller;
use Hydrogen\Controller;
use Hydrogen\MultiTemplateRenderer;
class Error extends Controller
{
use MultiTemplateRenderer;