Skip to content

Instantly share code, notes, and snippets.

View SimonVanherweghe's full-sized avatar
🍜
Raming

Simon Vanherweghe SimonVanherweghe

🍜
Raming
View GitHub Profile
@alesmenzel
alesmenzel / pick-random-element-based-on-probability.js
Last active June 28, 2024 18:00
Select random element from array by probability
const arr = ['A', 'B', 'C'];
// Probability map
const weight = {
A: 0.5,
B: 0.3,
C: 0.2
};
const find = input =>
@mxstbr
mxstbr / Readme.md
Last active August 20, 2024 12:43
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
@jamescmartinez
jamescmartinez / snapchat_decrypt.rb
Last active August 13, 2023 20:23
Snapchat Image Decrypt - This Ruby script decrypts the blob received from the `bq/blob` endpoint. Many thanks to @kivikakk, @adamcaudill, @tlack, and @NeilHanlon for inspiration, code, guides, and of course, the encryption key.
#!/usr/bin/env ruby
require 'openssl'
data = File.open('blob', 'r:ASCII-8BIT').read
c = OpenSSL::Cipher.new('AES-128-ECB')
c.decrypt
c.key = 'M02cnQ51Ji97vwT4'
o = ''.force_encoding('ASCII-8BIT')
data.bytes.each_slice(16) { |s| o += c.update(s.map(&:chr).join) }