Skip to content

Instantly share code, notes, and snippets.

@gasman
gasman / encode.py
Created October 25, 2020 12:23
Encoding a file as a Youtube video - https://www.youtube.com/watch?v=hyqLv2_zBdA
# Encode inputfile.tar.gz as a series of video frames
# Frames are written to frames/frameNNNN.png
from PIL import Image
with open('inputfile.tar.gz', 'rb') as f:
data = f.read()
WIDTH = 120
HEIGHT = 90
CHUNK_SIZE = int((WIDTH * HEIGHT) / 8)
@mikaello
mikaello / group-objects-by-property.md
Last active December 17, 2024 07:57 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group array of JavaScript objects by keys

This fork of JamieMason's implementation changes the key parameter to be an array of keys instead of just a single key. This makes it possible to group by multiple properties instead of just one.

Implementation

const groupBy = keys => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = keys.map(key => obj[key]).join('-');
@sidneys
sidneys / library.on-element-ready.js
Last active December 22, 2023 02:25
UserScript | Library | onElementReady ES6
// ==UserScript==
// @name Library: onElementReady ES7
// @namespace org.sidneys.userscripts
// @homepage https://gist.githubusercontent.com/sidneys/ee7a6b80315148ad1fb6847e72a22313/raw/
// @version 0.8.1
// @description Detect any new DOM Element by its CSS Selector, then trigger a function. Includes Promise- & Callback interface. Based on ES6 MutationObserver. Ships legacy waitForKeyElements interface, too.
// @author sidneys
// @icon https://i.imgur.com/nmbtzlX.png
// @match *://*/*
// ==/UserScript==
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@umidjons
umidjons / youtube-dl-download-audio-only-on-best-quality.md
Last active November 14, 2024 21:20
Download Audio from YouTube with youtube-dl

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

# Step 1 - install java 1.8
yum install java-1.8.0-openjdk.x86_64
# Step 2 - install jmeter 3.2
curl https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-3.2.tgz > $HOME/apache-jmeter-3.2.tgz
tar -xvzf $HOME/apache-jmeter-3.2.tgz
ln -s $HOME/apache-jmeter-3.2 $HOME/jmeter
# Step 3 - add to your path in ~/.bashrc
export JMETER_HOME=$HOME/jmeter
@destan
destan / ParseRSAKeys.java
Last active March 31, 2025 23:14
Parse RSA public and private key pair from string in Java
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
@arieljannai
arieljannai / mysql_sequence.sql
Last active October 7, 2024 06:24
creating sequence with nextval, currval, setval in mysql
-- based on http://www.microshell.com/database/mysql/emulating-nextval-function-to-get-sequence-in-mysql/
-- might be needed
-- SET GLOBAL log_bin_trust_function_creators = 1;
CREATE TABLE `sequence_data` (
`sequence_name` varchar(100) NOT NULL,
`sequence_increment` int(11) unsigned NOT NULL DEFAULT 1,
`sequence_min_value` int(11) unsigned NOT NULL DEFAULT 1,
`sequence_max_value` bigint(20) unsigned NOT NULL DEFAULT 18446744073709551615,
@jonmaim
jonmaim / csv2js.js
Last active November 23, 2020 11:00
Function takes a CSV (header + data) string as input and gives back a JS object.
// Start from https://gist.github.com/iwek/7154578#file-csv-to-json-js
// and fix the issue with double quoted values
function csvTojs(csv) {
var lines=csv.split("\n");
var result = [];
var headers = lines[0].split(",");
for(var i=1; i<lines.length; i++) {
var obj = {};
@marcocarnazzo
marcocarnazzo / 030_update_platform_config.js
Last active May 31, 2019 15:31
Ionic/Cordova update platform config
#!/usr/bin/env node
/** This hook updates platform configuration files based on preferences and config-file data defined in config.xml.
Currently only the AndroidManifest.xml and IOS *-Info.plist file are supported.
See http://stackoverflow.com/questions/28198983/ionic-cordova-add-intent-filter-using-config-xml
Preferences:
1. Preferences defined outside of the platform element will apply to all platforms
2. Preferences defined inside a platform element will apply only to the specified platform