This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NextImage from 'next/image' | |
import { useCallback } from 'react' | |
import compact from 'lodash/compact' | |
const CLOUDINARY_HOST = 'https://some-domain.mo.cloudinary.net' | |
type ImageLoaderProps = { | |
src: string | |
width: number | |
quality?: number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { migrateDatabase } from './typeormMigrationUtills' | |
;(async () => { | |
await migrateDatabase() | |
})() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buttons=[] | |
document.querySelectorAll('ytd-playlist-video-renderer ytd-menu-renderer #button.style-scope.yt-icon-button').forEach(b => buttons.push(b)) | |
while(bs.length > 0) { | |
let button = buttons.pop() | |
button.click() | |
await (new Promise(resolve => setTimeout(resolve, 500))) | |
let dropdownItems = []; | |
document.querySelectorAll('tp-yt-paper-listbox tp-yt-paper-item').forEach(n => dropdownItems.push(n)); | |
dropdownItems.find(e => e.textContent.includes('Remove from Watch later')).click() | |
await (new Promise(resolve => setTimeout(resolve, 3000))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationMailer < ActionMailer::Base | |
def new_blog_post(blog_post, subscriber) | |
# by calling "store_message" we are saying that this | |
# emails need to be saved in our database | |
# for further tracking | |
store_message( | |
email_name: 'new_blog_post', | |
entity: blog_post, | |
user: subscriber | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 100 | |
def random_uri | |
URI("https://rickandmortyapi.com/api/character/#{rand(399) + 1}") | |
end | |
Benchmark.bm do |x| | |
x.report do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ProfilePage: NextPage = () => { | |
return ( | |
<PageLayout> | |
{/* PAGE BODY */} | |
</PageLayout> | |
) | |
} | |
// THE ACTUAL USAGE | |
requireAuth(ProfilePage) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhoneVerification | |
class << self | |
# time that user has before a code expires | |
EXPIRATION = 5.minutes | |
# an SMS can't be sent more frequently than that | |
TIME_BEFORE_RESEND = 30.seconds | |
# how many times can a user enter an invalid code | |
MAX_ATTEMPTS = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TextEncryptor | |
class << self | |
def encrypt(text) | |
text = text.to_s unless text.is_a? String | |
len = ActiveSupport::MessageEncryptor.key_len | |
salt = SecureRandom.hex len | |
key = ActiveSupport::KeyGenerator.new(secret).generate_key salt, len | |
crypt = ActiveSupport::MessageEncryptor.new key | |
encrypted_data = crypt.encrypt_and_sign text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function MapsStaticApiExample({ | |
markers, | |
height, | |
width, | |
center, | |
zoom, | |
}: Props) { | |
return ( | |
<img | |
alt="Map Preview" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Whenever::Output::Cron.new(:monday, nil, '3:01 am', {}).time_in_cron_syntax | |
# => "1 3 * * 1" |
NewerOlder