Skip to content

Instantly share code, notes, and snippets.

export default function(originalPromise, delay = 750) {
return Promise.all([
originalPromise,
new Promise(resolve => {
setTimeout(() => resolve(), delay)
}),
]).then(result => result[0])
}
// Usage
@unrealwill
unrealwill / collisionLSH.py
Created August 8, 2021 10:20
Proof of Concept : generating collisions on a neural perceptual hash
import tensorflow as tf #We need tensorflow 2.x
import numpy as np
#The hashlength in bits
hashLength = 256
def buildModel():
#we can set the seed to simulate the fact that this network is known and doesn't change between runs
#tf.random.set_seed(42)
model = tf.keras.Sequential()
@freekmurze
freekmurze / 2021_02_17_103523_migrate_to_jetstream.php
Last active June 11, 2022 19:55
Migrate classic Spark tables to Jetstream + new Spark
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MigrateToJetstream extends Migration
{
public function up()
{
@reinink
reinink / inertia-attribute.js
Last active June 14, 2022 03:29
Global Inertia.js click event handler
import { Inertia } from '@inertiajs/inertia'
document.addEventListener('click', (event) => {
if (
event.target.tagName.toLowerCase() === 'a' &&
event.target.hasAttribute('inertia') &&
!event.target.isContentEditable &&
!event.defaultPrevented &&
!event.shiftKey &&
!event.ctrlKey &&
export default defineConfig({
plugins: [
laravel(['resources/js/app.js']),
{
name: 'ziggy',
enforce: 'post',
handleHotUpdate({ server, file }) {
if (file.includes('/routes/') && file.endsWith('.php')) {
exec('php artisan ziggy:generate', (error, stdout) => error === null && console.log(` > Ziggy routes generated!`))
}
@natzir
natzir / puppeteer-fetch-and-render.js
Last active August 25, 2023 23:44
Fetch and Render as Googlebot
// This code allows you to render a page as Googlebot with puppeter (headless Chrome).
// It even renders elements with the lazy-load implemented through IntersectionObserver.
// Copy and paste it here: https://try-puppeteer.appspot.com/
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Descriptors for other mobile devices: https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts
const mobile = {
name: 'Nexus 5X',
// Discord all events!
// A quick and dirty fleshing out of the discord.js event listeners (not tested at all!)
// listed here -> https://discord.js.org/#/docs/main/stable/class/Client
// Learn from this, do not just copy it mofo!
//
// Saved to -> https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584
/*
koad-was-here
// This list comes from Wikipedia deprecated timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
const deprecatedList = [
{ old: 'Australia/ACT', new: 'Australia/Sydney' },
{ old: 'Australia/LHI', new: 'Australia/Lord_Howe' },
{ old: 'Australia/North', new: 'Australia/Darwin' },
{ old: 'Australia/NSW', new: 'Australia/Sydney' },
{ old: 'Australia/Queensland', new: 'Australia/Brisbane' },
{ old: 'Australia/South', new: 'Australia/Adelaide' },
{ old: 'Australia/Tasmania', new: 'Australia/Hobart' },
{ old: 'Australia/Victoria', new: 'Australia/Melbourne' },
@andreia
andreia / mermaid-diagrams.md
Created March 12, 2022 23:24
Mermaid diagrams on Github markdown

Flowchart

flowchart LR
    A[If I] --> B{could};
    B -- Yes --> C[I would];
    C --> D[Let it go, Surrender, Dislocate];

Pie chart

@lxe
lxe / README.md
Last active February 27, 2024 21:19
How to get oobabooga/text-generation-webui running on Windows or Linux with LLaMa-30b 4bit mode via GPTQ-for-LLaMa on an RTX 3090 start to finish.

How to get oobabooga/text-generation-webui running on Windows or Linux with LLaMa-30b 4bit mode via GPTQ-for-LLaMa on an RTX 3090 start to finish.

This guide actually works well for linux too. Just don't bother with the powershell envs

  1. Download prerequisites

  2. (Windows Only) Open the Conda Powershell.