Skip to content

Instantly share code, notes, and snippets.

View rap2hpoutre's full-sized avatar

Raphaël Huchet rap2hpoutre

View GitHub Profile
@chuckplantain
chuckplantain / executionOrderJestJasmine.js
Created April 5, 2018 13:59
Execution order of async Jest/Jasmine test code
/**
* Demonstrate execution order of code in Jest/Jasmine
*/
function resolveAfter2Seconds(message) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(message)
}, Math.ceil(Math.random() * 5000))
})
@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 {
@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) {
@kerryboyko
kerryboyko / README.md
Last active April 26, 2023 16:08
VueJS Best Practices Guide

Deverus Vue.js Style Guide

Guide for developing Vue.js applications.

v. 0.0.1

Vue.js is an amazing framework, which can be as powerful as Angular or React, the two big heavy hitters in the world of front-end frameworks.

However, most of Vue's ease-of-use is due to the use of Observables - a pattern that triggers re-renders and other function calls with the reassignment of a variable.

@calebporzio
calebporzio / timer_helpers.php
Last active August 18, 2019 00:07
A simple helper function and macro for timing php scripts and eloquent queries
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();
@jrmuizel
jrmuizel / PopularCrates.md
Created April 21, 2017 19:59
Popular crates
@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
@InfoSec812
InfoSec812 / jsonb_patch.sql
Last active April 17, 2024 21:08
Pure PostgreSQL implementation of JSONPatch
!!
!! Implementation of JSONPatch (http://jsonpatch.com/) using PostgreSQL >= 9.5
!!
CREATE OR REPLACE FUNCTION jsonb_copy(JSONB, TEXT[], TEXT[]) RETURNS JSONB AS $$
DECLARE
retval ALIAS FOR $1;
src_path ALIAS FOR $2;
dst_path ALIAS FOR $3;
tmp_value JSONB;
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();