Skip to content

Instantly share code, notes, and snippets.

View giovannipds's full-sized avatar
💭
I may be slow to respond.

G. Pires giovannipds

💭
I may be slow to respond.
View GitHub Profile
@addisonschultz
addisonschultz / useScript.tsx
Last active October 28, 2023 10:02
A React hook that lets you add script tags to a component. Useful when needing to load scripts for components in Framer X.
import * as React from "react"
import { useState, useEffect } from "react"
// Hook
let cachedScripts = []
export function useScript(src) {
// Keeping track of script loaded and error state
const [state, setState] = useState({
loaded: false,
@valterh4ck3r
valterh4ck3r / cnpj.pipe.ts
Created July 13, 2018 20:42
Angular Pipe CNPJ
@Pipe({name: 'cnpj'})
export class CNPJPipe implements PipeTransform {
transform(value) {
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/g,"\$1.\$2.\$3\/\$4\-\$5")
}
}
@remy
remy / ActiveLink.js
Last active April 12, 2024 08:33
Next.js version of `activeClassName` support.
@Laeyoung
Laeyoung / uitextfieldwithpadding
Last active July 20, 2018 14:02 — forked from lawreyios/uitextfieldwithpadding
Add padding to UITextField - Swift 3.0
class CustomSearchTextField: UITextField {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsetsMake(0, 15, 0, 15))
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
@lawreyios
lawreyios / uitextfieldwithpadding
Last active December 17, 2018 15:39
Add padding to UITextField - Swift 3.0
class CustomSearchTextField: UITextField {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsetsMake(0, 15, 0, 15))
}
override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@BARNZ
BARNZ / GenerateToken.php
Last active September 7, 2023 18:39
Generate a Laravel 5.x hash/token
<?php
use Illuminate\Support\Facades\Password;
# Generate a token in the same style as laravels password reset tokens.
# Will generate something like: 785f616c4978a87ad65a899ed4133b358a4697649c55b0965a7ebb7486bd9801
/** @var DatabaseTokenRepository */
$repo = Password::getRepository();
$token = $repo->createNewToken($user);

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

@odan
odan / xampp_php7_xdebug.md
Last active April 17, 2024 05:36
Installing Xdebug for XAMPP