Skip to content

Instantly share code, notes, and snippets.

View alxmtr's full-sized avatar

Alex M alxmtr

View GitHub Profile
@alxmtr
alxmtr / gulpfile.js
Last active June 23, 2022 03:22
Sass & Pug + BrowserSync
const { src, dest, watch, series } = require('gulp')
const pug = require('gulp-pug')
const sass = require('gulp-sass')
const browserSync = require('browser-sync').create()
// Compile pug files into HTML
function html() {
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
100.42 .toLocaleString('en-US', { style: 'currency', currency: 'USD' })
100.42 .toLocaleString('fr-FR', { style: 'currency', currency: 'EUR' })
100.42 .toLocaleString('ja-JP', { style: 'currency', currency: 'YEN' })
from random import sample
from string import ascii_letters, digits
def generate_password(length):
return ''.join(sample(ascii_letters + digits, length))
print(generate_password(10))
@alxmtr
alxmtr / one-liners.js
Created April 1, 2019 14:48
JavaScript one-liners
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = ms => (new Promise(resolve => setTimeout(resolve, ms))
// Type this in your code to break chrome debugger in that line (breakpoint).
debugger
// Just plain english.
@alxmtr
alxmtr / laravel-snippets.md
Last active March 30, 2023 13:41
Laravel Snippets

Manually register a user in Laravel (Tinker)

User::create([
    'email' => 'name@example.com', 
    'name' => 'Alex', 
    'password' => bcrypt('password')
])

Update a product if the amount is upper to 0

@alxmtr
alxmtr / list_models.php
Last active April 1, 2022 17:34
Laravel: List all existing app models.
<?php
if (! function_exists('list_models')) {
/**
* Return a list of existing app models.
*
* @return array
*/
function list_models(): array
{