Skip to content

Instantly share code, notes, and snippets.

View JaneJeon's full-sized avatar

Jane Jeon JaneJeon

View GitHub Profile
@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()
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active April 26, 2024 13:33
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@bitmvr
bitmvr / example--parse-semver-with-bash.sh
Last active January 6, 2024 14:02
Parsing SemVer with Bash
#!/usr/bin/env bash
VERSION="$1"
VERSION="${VERSION#[vV]}"
VERSION_MAJOR="${VERSION%%\.*}"
VERSION_MINOR="${VERSION#*.}"
VERSION_MINOR="${VERSION_MINOR%.*}"
VERSION_PATCH="${VERSION##*.}"
echo "Version: ${VERSION}"
According to all known laws of aviation, there is no way a bee should be able to fly.
Its wings are too small to get its fat little body off the ground.
The bee, of course, flies anyway because bees don't care what humans think is impossible.
Yellow, black. Yellow, black. Yellow, black. Yellow, black.
Ooh, black and yellow!
Let's shake it up a little.
Barry! Breakfast is ready!
Coming!
Hang on a second.
Hello?
@Jobarion
Jobarion / THX.java
Last active July 9, 2023 21:07
THX Deep Note Generator
/*
MIT License
Copyright (c) 2018 Jonas Balsfulland
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@dalcib
dalcib / ajvValidator.js
Created January 24, 2018 04:36
AJV validator to use with react-final-form
import Ajv from 'ajv/dist/ajv.min';
import AddIf from 'ajv-keywords/keywords/if';
const makeValidator = (schema) => {
const ajv = new Ajv({ allErrors: true, coerceTypes: true });
// Add If-then-else from ajv-keywords package
AddIf(ajv);
// Add custom keyword
@WaleedAshraf
WaleedAshraf / cookies.md
Last active March 21, 2023 08:42
Mocking Express Session For Tests

How to mock express session?

sinon is being used to mock methods in tests. It is one of the most used package for testing. But Is there a way to mock session objects in tests for express?

I'm working on a project where I upload images to s3 in bulk (albums) and than further apply some processing like resizing/compression/editing on them.

It's a express app with middlewares for authorization, authentication, setting context and is working fine. Recently I started adding testcases for different routes using mocha. I'm using cookie-session for session handling in app.

For one route, I needed to mock req.session object. (Need to set it's value before calling the other route.)

@aaronshaf
aaronshaf / generator.js
Last active May 13, 2022 11:00
Use async generators and async iterators with DynamoDB's scan
const { docClient } = require('../services/dynamodb')
exports.findAllItems = async function* () {
let response = {}
let ExclusiveStartKey
do {
response = await docClient.scan({
TableName: 'mytable',
Limit: 500,
ExclusiveStartKey
@joyrexus
joyrexus / README.md
Last active February 19, 2024 17:15 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@dedy-purwanto
dedy-purwanto / 10fastfinger_bot.js
Created December 22, 2011 12:44
BOT for 10fastfingers, automatic typing with adjustable speed
/*
* BOT for 10fastfingers, automatic typing with adjustable speed
* ================================================================
*
* bored in my apartment and decided to hack this game: http://indonesian-speedtest.10fastfingers.com/
* just start the game, when you're ready to type, DON'T TYPE ANYTHING, open up
* your Developer Tools in Chrome (CTRL+SHIFT+J) and click Console tab, and
* then paste the whole code below, then press enter, and enjoy the show.
*
* twitter.com/kecebongsoft