Skip to content

Instantly share code, notes, and snippets.

@PofMagicfingers
PofMagicfingers / readMongoDBSize.js
Last active June 30, 2024 14:23 — forked from ovntatar/readMongoDBSize.js
read human readable size from MongoDB collections
# inspired by https://gist.github.com/joeyAghion/6511184
function getReadableFileSizeString(fileSizeInBytes) {
var i = -1;
var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
do {
fileSizeInBytes = fileSizeInBytes / 1024;
i++;
} while (fileSizeInBytes > 1024);
@PofMagicfingers
PofMagicfingers / memories_history2bash.js
Created January 31, 2022 09:42
Download all stories from Snapchat data archive ( memories_history.html ) by converting them to a bash script using curl
// Open memories_history.html, and open the developer console, paste this code :
function download(filename, text) {
var element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(text)
);
element.setAttribute("download", filename);
@PofMagicfingers
PofMagicfingers / install.sh
Created January 7, 2022 16:26
How to install solargraph for legacy Ruby 2.4
#/bin/sh
gem install -v 1.5.2 racc
gem install -v 1.10.10 nokogiri
gem install -v 1.19.2 parallel
gem install -v 0.39.17 solargraph
#!/bin/bash
{ echo -e "\n# $(basename "$PWD")\n" ; sed -e 's/#.*$//' -e '/^$/d' modman | awk '{ print $2 }' } # >> ../../htdocs/.gitignore
@PofMagicfingers
PofMagicfingers / episode.rb
Created June 30, 2019 09:11
Season, episode and episode type inferred from title
def infer_type_season_and_episode!
# try to detect episode number
tome_chapter_matcher = /(?>\bT(?>ome)?[\s\.]*(?<tome>[0-9]+)\b)?[\s\.]*\bCh(?>apitre|apter)?[\s\.]*(?<chapter>[0-9]+)\b/i
season_episode_matcher = /\b(S(?>eason|aison)?[\s\.]*(?<season>[0-9]+)[\s.]*)?(E|É)(?>pisode|p)?[\s\.]*(?<episode>[0-9]+)\b/i
simple_episode_matcher = /(?>#{::Regexp.escape(self.feed.try(:title))}\s*\#?|\#\s*|°\s*|(É|E)(?>pisode|p)[\s\.]*)(?<episode>[0-9]+)\b(?>$|\.?\s+|\:)/i
_tome = _chapter = _season = _episode = 0
tome_chapter_match = tome_chapter_matcher.match(self.title)
if tome_chapter_match
@PofMagicfingers
PofMagicfingers / 00-usb-keyboard.rules
Last active May 26, 2024 03:59
Keyboard layout auto change with udev
ATTRS{idVendor}=="060b", ATTRS{idProduct}=="5252", OWNER="pof"
ACTION=="add", RUN+="/usr/local/bin/usb-keyboard-udev in"
ACTION=="remove", RUN+="/usr/local/bin/usb-keyboard-udev out"
### Keybase proof
I hereby claim:
* I am pofmagicfingers on github.
* I am pofmagicfingers (https://keybase.io/pofmagicfingers) on keybase.
* I have a public key ASAJuRDd9LX_Qj1QlwHJT90fBHf0tpHiYfgq0Herkby4oAo
To claim this, I am signing this object:
@PofMagicfingers
PofMagicfingers / redmine.sh
Last active October 1, 2018 14:09
shortcuts to Redmine with rofi
#!/bin/bash
config_file=$HOME/.config/redmine
if [ ! -f $config_file ]; then
cat << Usage
Please add your REDMINE_API_KEY and REDMINE_URL
into a file at ~/.config/redmine
REDMINE_API_KEY="apikey"
@PofMagicfingers
PofMagicfingers / server.js
Created September 17, 2018 13:29
Really simple and naive nodejs args parsing
const parseArgs = (args, parsers) =>
Object.assign(
{},
...parsers.map(parser => {
const parsed = Object.assign(
{},
...args.map(arg => {
const parsed = arg.match(parser);
return (parsed && parsed.groups) || {};
})
<script type="text/javascript">
jQuery(window).load(function () {
var size = 1;
var button = 1;
var button_class = "gallery-header-center-right-links-current";
var normal_size_class = "gallery-content-center-normal";
var full_size_class = "gallery-content-center-full";
var $container = jQuery('#gallery-content-center');
var wm;