Skip to content

Instantly share code, notes, and snippets.

@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@rxaviers
rxaviers / gist:7360908
Last active October 19, 2024 11:20
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
function logTimes(message) {
performance.mark(message); // this one is for WebPageTest
console.timeStamp(message); // this is for the Performance tab in Chrome DevTools
console.info(message, performance.now()); // this is for the console, duh
// this here is for Google Analytics
ga('send', {
hitType: 'timing',
timingCategory: 'Performance',
timingVar: message,
@vasiltabakov
vasiltabakov / FigureOptions.ts
Created October 7, 2017 09:47
Quill editor editable image caption
import Quill from 'quill';
import {TaskerFigure} from './TaskerFigure';
import Parchment from 'parchment';
export class FigureOptions {
quill: Quill;
figure;
overlay;
linkRange;
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@mattdfloyd
mattdfloyd / CreateProductJob.php
Created June 21, 2018 02:26
Laravel's firstOrCreate race conditions
<?php
namespace App\Jobs;
use App\Product;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Redis;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
@leMaur
leMaur / tabbing.js
Last active September 5, 2019 07:19
(function (window, document) {
'use strict';
let className = 'tabbing';
let handleFirstTab = function (e) {
if (e.keyCode === 9) {
document.body.classList.add(className);
window.removeEventListener('keydown', handleFirstTab);
window.addEventListener('mousedown', handleMouseDownOnce);
@laravel-shift
laravel-shift / .php-cs-fixer.php
Last active August 8, 2024 23:45
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@leMaur
leMaur / tailwind.colors.js
Created September 5, 2019 07:04
Custom colors for Tailwindcss taken from Mineral-ui project
// ******************************
// https://mineral-ui.com/color
// ******************************
module.exports = {
colors: {
transparent: 'transparent',
black: '#1d1f24',
white: '#ffffff',
@leMaur
leMaur / tailwind-plugin.grid.js
Last active September 5, 2019 07:18
Basic Grid box
const _ = require('lodash')
module.exports = function ({addBase, addUtilities, e, theme, variants}) {
const gridGaps = theme('gridGap', {})
const gridTemplates = theme('gridTemplate', {})
const gridGapVariants = variants('gridGap', [])
const gridTemplateVariants = variants('gridTemplate', [])
const gapUtilities = _.map(gridGaps, (size, name) => ({
[`.grid-gap-${e(name)}`]: {gridGap: `${size}`},