Skip to content

Instantly share code, notes, and snippets.

View rap2hpoutre's full-sized avatar

Raphaël Huchet rap2hpoutre

View GitHub Profile
@Djuki
Djuki / deploy.sh
Last active August 29, 2015 14:04
Deploy script for Laravel apps
# stop script on error signal
set -e
# delete deployment folder if script exit before end last time
if [ -d "/home/forge/deployment" ]; then
rm -R /home/forge/deployment
fi
# set up your env variables if your app using them
export DB_HOST=localhost

###Edit this file

/etc/nginx/nginx.conf

###Add this line anywhere inside the http { } block:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

###Go to your Forge panel and restart Nginx

@caseyamcl
caseyamcl / come-on-really.md
Created February 19, 2015 18:20
Ahhhhhhhhh!!!!

HOLY GAWD PEOPLE..

  • Don't write all your new code on the production machine!
  • Use a VCS!
  • Document your functions using DocBlocks!
  • Document your API (at least LIST the endpoints)... I have to decipher the meaning from your code, and that isn't really clear
  • Use a single identifier as the primary ID in the API for a resource (ie don't return a list of group ids for listing groups and then expect the group name as the identifying parameter for modifying a group)
  • Use a consistent model for representing the same data model in different endpoints!
  • Don't concatenate fields in the API results unless there is a good reason to (e.g first name and last name)
  • Don't expose the underlying database logic. This is leaky abstraction, especially when you do it inconsistently!!
@fetus-hina
fetus-hina / shuffle.php
Created September 18, 2012 11:28
mt_shuffle(), array_shuffle()
<?php
function fy_shuffle(array &$array, $rand = 'mt_rand') {
$array = array_values($array);
for($i = count($array) - 1; $i > 0; --$i) {
$j = $rand(0, $i);
if($i !== $j) {
list($array[$i], $array[$j]) = array($array[$j], $array[$i]);
}
}
return true;
@MD4
MD4 / jojoChainableForEach.js
Last active July 20, 2016 09:36
🐒 Chainable forEach monkey patch !
(function(oldForEach) {
Array.prototype.forEach = function() {
oldForEach.apply(this, arguments);
return this;
};
}(Array.prototype.forEach));
[1, 2, 3]
.forEach(item => console.log(1, item))
.forEach(item => console.log(2, item))
@migrs
migrs / Kernel.php
Last active April 9, 2017 20:46
newrelic patch for laravel5.2
<?php namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
protected $middleware = [
\App\Http\Middleware\NewRelicPatch::class,
//... your other middlewares
];
@ericelliott
ericelliott / software-testing.md
Last active November 18, 2017 17:39
software testing

Testing JavaScript Apps

Most apps should eventually have two or three sets of test suites: Unit tests, integration tests, and functional tests.

A note about examples:

We'll be using ES6 syntax just for reading simplicity. () => means function, let is block-scoped var (used here just to remind the reader that we're talking about ES6), and (...args) creates an args array containing all the arguments that follow the ....

Unit Tests

@NoelDeMartin
NoelDeMartin / Browser.php
Created November 30, 2017 08:52
Laravel Dusk Mail mocking proposal
<?php
namespace Tests\Browser\Dusk;
use Tests\Testing\MailFake;
use Laravel\Dusk\Browser as BaseBrowser;
class Browser extends BaseBrowser {
public function fake($service) {
@yann-yinn
yann-yinn / index.jsx
Created April 1, 2018 18:51
Get content from graphCMS with Next.js
import React from "react";
import { request, GraphQLClient } from "graphql-request";
export default class HomePage extends React.Component {
static async getInitialProps() {
const query = `{
allPosts {
id
slug
coverImage {
@imliam
imliam / pagination.blade.php
Last active November 26, 2018 15:23
Laravel 5 - Bootstrap 4 Pagination
<?php
/*
|--------------------------------------------------------------------------
| Laravel 5, Bootstrap 4 Pagination
|--------------------------------------------------------------------------
|
| A partial view to handle pagination for collections in Laravel's query
| builder or Eloquent ORM, styled with Bootstrap 4.
|
| The pagination displays like the following, where * denotes the current