Skip to content

Instantly share code, notes, and snippets.

queryset = Garage.objects.filter(user=user).exclude(status=Garage.TEMPLATE).order_by("-created_at")
page = self.paginate_queryset(queryset)
serializer = GarageViewSerializer(page, many=True)
return self.get_paginated_response(serializer.data)
@abcsun
abcsun / app\Http\Controllers\AuthenticationController.php
Created March 10, 2016 04:25 — forked from jonsa/app\Http\Controllers\AuthenticationController.php
Minimal Lumen framework configuration with Dingo and JWT
<?php
namespace App\Http\Controllers;
use Tymon\JWTAuth\JWTAuth;
use Illuminate\Http\Request;
use Tymon\JWTAuth\Exceptions\JWTException;
/**
* Class AuthenticationController
DB::listen(
function ($sql) {
// $sql is an object with the properties:
// sql: The query
// bindings: the sql query variables
// time: The execution time for the query
// connectionName: The name of the connection
// To save the executed queries to file:
// Process the sql and the bindings:
@abcsun
abcsun / jwt-parseAuthHeader
Created March 8, 2016 08:47
JWT中解析http header中的authorization中所携带的token值
/**
* Parse token from the authorization header.
*
* @param string $header
* @param string $method
*
* @return false|string
*/
protected function parseAuthHeader($header = 'authorization', $method = 'bearer')
@abcsun
abcsun / setting-up-push-to-deploy-with-git.md
Created March 2, 2016 03:31
setting-up-push-to-deploy-with-git

from Kris Jordan

November 2nd, 2013 Setting up Push-to-Deploy with git

I first set up a push-to-deploy system with git and puppet for a side project a few years back. It worked so well I transitioned NMC's development process onto it for all of our new projects starting last year. It offers the simplicity of the "push-to-deploy" model Heroku pioneered, with full control and flexibility over the operating system environment.

I've started thinking about my next iteration of this system for Didsum, and using pushing for more than just deployment purposes. The Push-to-______ pattern is powerful and easy to use, once you know how the pieces fit together. In this post, I'll walk through the setting up Push-to-Deploy from the ground up.

(I'm assuming a working knowledge of: terminal, git, and a scripting language.)

@abcsun
abcsun / 0_reuse_code.js
Created February 25, 2016 07:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console