Skip to content

Instantly share code, notes, and snippets.

View Giovancruz's full-sized avatar
📚
Studying new stacks

Giovan Cruz Giovancruz

📚
Studying new stacks
View GitHub Profile
@Luisgustavom1
Luisgustavom1 / ComposeProviders.tsx
Last active December 27, 2022 19:10
Compose React Providers to avoid too much chaining
import React from 'react'
interface IComposeProvidersProps {
with: Array<React.ElementType>
children: React.ReactNode
}
export const ComposeProviders = ({
with: Providers,
children,
@stevebauman
stevebauman / GeneratesXml.php
Created December 10, 2019 06:29
A Scheduled Tasks XML File Generator using PHP, Laravel and Spatie - Array-to-XML
<?php
namespace App\System;
use Spatie\ArrayToXml\ArrayToXml;
trait GeneratesXml
{
/**
* The XML template.
@greeflas
greeflas / install-toolbox.sh
Last active March 29, 2024 07:53
JetBrains Toolbox installation script for Ubuntu - https://www.jetbrains.com/toolbox/app/
#!/bin/bash
set -e
if [ -d ~/.local/share/JetBrains/Toolbox ]; then
echo "JetBrains Toolbox is already installed!"
exit 0
fi
echo "Start installation..."
@LoyEgor
LoyEgor / gulpfile.js
Last active March 13, 2023 17:22
best image compression settings (gulp-imagemin)
// install
// npm i gulp-cache gulp-imagemin imagemin-pngquant imagemin-zopfli imagemin-mozjpeg imagemin-giflossy -f
// node node_modules/jpegtran-bin/lib/install.js
// node node_modules/gifsicle/lib/install.js
// node node_modules/zopflipng-bin/lib/install.js
// node node_modules/mozjpeg/lib/install.js
// node node_modules/giflossy/lib/install.js
// node node_modules/pngquant-bin/lib/install.js
@TaylorAckley
TaylorAckley / gulpfile-minimal.js
Last active June 29, 2019 18:30
Example Gulpfile with concat, minify, bundle and image optimization
"use strict";
var gulp = require('gulp'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
notify = require('gulp-notify'),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
@sergiolopes
sergiolopes / lazyload-v2.js
Last active February 11, 2024 23:54
Lazy load de imagens beeem simples
(function(){
// como vamos usar o throttle varias vezes (no scroll e no resize),
// encapsulei essa funcionalidade numa função
function throttle(fn) {
fn.jarodei = false;
return function(){
if (fn.jarodei) return;
fn.jarodei = true;
@leymannx
leymannx / gulpfile.js
Last active July 13, 2023 15:29
Gulp Sass with autoprefixer and minify.
var gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
cssmin = require('gulp-cssnano'),
prefix = require('gulp-autoprefixer'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
sassLint = require('gulp-sass-lint'),
sourcemaps = require('gulp-sourcemaps');
// Temporary solution until gulp 4
@heiswayi
heiswayi / .htaccess
Last active June 15, 2023 17:03 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
# 301 Redirects for .htaccess
# ===========================
# Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
# Redirect an entire site:
Redirect 301 / http://www.domain.com/
# Redirect an entire site to a subfolder
@krisbulman
krisbulman / countCSSRules.js
Last active August 25, 2022 19:53 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE. — This snippet has been modified to count more than just the first level of CSSStyleRule objects within CSSMediaRule.
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];