Skip to content

Instantly share code, notes, and snippets.

@nilsandrey
nilsandrey / SendToTypefull-bookmarklet.js
Last active May 2, 2024 03:08
Use this code on a new bookmark to send current page to a new Typefully draft.
javascript:(function(){f='https://typefully.com/?new='+encodeURIComponent(document.title)+'%250A'+encodeURIComponent(window.location.href);a=function(){if(!window.open(f))location.href=f};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()
@nokotan
nokotan / extract-comments.py
Created February 26, 2021 16:32
Extract Comments in C/C++ Source File
#!/usr/bin/python3
from clang.cindex import Index, Config, CursorKind
import json as JsonUtil
import os, io, sys
class MyTreeWalker:
def __init__(self):
@almonk
almonk / SnappyWindow.swift
Last active May 2, 2024 03:05
SnappyWindow – A NSWindow that acts like the PIP Video Window from Safari
//
// SnappyWindow.swift
// A NSWindow that snaps to corners
//
// Created by Alasdair Monk on 03/02/2021.
//
import Foundation
import Cocoa
@caseywatts
caseywatts / bookmarkleting.md
Last active May 2, 2024 03:04
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.

@dinh
dinh / bookmarkleting.md
Created January 31, 2023 10:28 — forked from caseywatts/bookmarkleting.md
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.

@sibelius
sibelius / woovi_challenge.md
Last active May 2, 2024 03:03
Woovi Challenge
@chrisdlangton
chrisdlangton / hmac_decorator.py
Last active May 2, 2024 03:03
Time-based HMAC signature SHA256, SHA512, SHA3-256, SHA3-384, SHA3-512, and BLAKE2 for Python Flask with Javascript Forge.js and Bash/OpenSSL/Curl clients
import hashlib
import hmac
from base64 import b64encode
from functools import wraps
from datetime import datetime, timedelta
from flask import request, abort
from flask_login import login_user
from models import User, ApiKey
def require_hmac(not_before_seconds: int = 3, expire_after_seconds: int = 3):
@ajumalp
ajumalp / Install Mosquitto MQTT on Synology NAS Server.txt
Last active May 2, 2024 03:00
Install Mosquitto MQTT on Synology NAS Server
From https://synocommunity.com add http://packages.synocommunity.com to your NAS package sources.
For that, go to NAS->Package Cnter->Click Settings->Package Sources tab.
Then from the community, you can see Mosquitto. Install it.
After installing, please stop the Mosquitto service before updating configuration. You can start service after changes.
Enable Admin login for Synology
Enable SSH in NAS
Download putty and connect to NAS Server
Login using admin
Change to root user [sudo -i, {use admin password}]
Find mosquitto.conf file [find / -name mosquitto.conf]
// <https://dev.to/jorik/country-code-to-flag-emoji-a21>
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
const array = [1, 2, 3, 4, 5];
array.groupBy((num, index, array) => {
return num % 2 === 0 ? 'even': 'odd';
});
// => { odd: [1, 3, 5], even: [2, 4] }>
const odd = { odd: true };
const even = { even: true };