Skip to content

Instantly share code, notes, and snippets.

@xarmengol
xarmengol / SetLocale.md
Last active February 6, 2024 01:46
Set locale for authenticated users in laravel

Intro

What we want to do is to set the locales of a laravel 5.6 application, by depending of the language of the authenticated user. We store the language preferences of a user on the database, in the users table.

Steps

Create a new Middleware:

php artisan make:middleware AuthUserSetLocale
@yisraeldov
yisraeldov / build_postfields.php
Last active August 27, 2019 11:45
create an array that can be passed to `CURLOPT_POSTFIELDS` that contains mutidimension arrays and `CURLFile`s
<?php
/**
* Use this to send data with multidimensional arrays and CURLFiles
* `curl_setopt($ch, CURLOPT_POSTFIELDS, build_post_fields($postfields));`
*
* @param $data
* @param string $existingKeys - will set the paramater name, probably don't want to use
* @param array $returnArray - Can pass data to start with, only put good data here
*
* @return array
@evanwill
evanwill / gitBash_windows.md
Last active April 17, 2024 08:53
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

@inexorabletash
inexorabletash / @ Indexed DB - N-Dimensional Select.md
Last active April 16, 2024 20:38
Indexed DB - N-dimensional selection

Indexed DB - N-Dimensional Selection

The problem

We have an index with keys of the form:

[ dim1, dim2, dim3, ... ]

e.g. created with: