Skip to content

Instantly share code, notes, and snippets.

View yuletide's full-sized avatar
🤘

Alex Yule yuletide

🤘
View GitHub Profile
@Zetaphor
Zetaphor / docker-selenium.sh
Last active November 15, 2023 03:05
Music download automation
docker pull selenium/standalone-chrome
docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome
@junosuarez
junosuarez / setup.md
Last active December 19, 2022 17:17
how to setup mastodon forwarding from your custom domain using webfinger and github pages

how to setup mastodon forwarding from your custom domain using webfinger and github pages

by @me@juno.lol

tldr

say you have your own domain, cool.example, and you'd rather use very@cool.example as your identity instead of cool23234543@mastodon.social. you can!

prerequisites

I'll assume you already have a repo setup with github pages turned on (or some other static site hosting), and that you already have a mastodon account somewhere.

theory

@jessejputnam
jessejputnam / array_methods_cheats.md
Created August 16, 2022 12:57
A cheatsheet for choosing JavaScript array methods

Choosing an array method

I want to...

Mutate the original array

  • Add to original:
arr.push
arr.unshift

How to deploy a webpage in 2022

Instructions for getting a [mostly] static website onto a custom domain, with https encryption, for [mostly] free. I'm finally writing this down after getting stuck on step 10 way too many times. Godspeed.

  1. Purchase the top-level domain - gandi.net is my current preferred registrar. Hopefully this will be the only cash you drop in this process.
  2. Create a new public repository on github.
  3. Clone the new repo locally and create your site content package, even starting with something as simple as a standalone index.html.
  4. Add a file called CNAME to the repo, containing only a single line with your just-purchased domain in it. e.g. domain.com.
  5. Commit the content to github.
  6. In the settings --> pages menu of the repository on github.com, point to the correct branch, and enter the domain under "Cu
@miguelmota
miguelmota / go_get_formula.rb
Last active January 4, 2023 22:23
Homebrew golang formula example
require "language/go"
class Cointop < Formula
desc "An interactive terminal based UI application for tracking cryptocurrencies"
homepage "https://cointop.sh"
url "https://github.com/miguelmota/cointop/archive/0.0.1.tar.gz"
sha256 "3b2b039da68c92d597ae4a6a89aab58d9741132efd514bbf5cf1a1a151b16213"
revision 1
head "https://github.com/miguelmota/cointop.git"
depends_on "go" => :build
@OleksiyRudenko
OleksiyRudenko / Build-and-Publish.md
Last active March 28, 2024 02:04
Building and publishing a web app @ github pages using ParcelJS
# Bash best practices and style-guide
Just simple methods to keep the code clean.
Inspired by [progrium/bashstyle](https://github.com/progrium/bashstyle) and [Kfir Lavi post](http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/).
## Quick big rules
* All code goes in a function
* Always double quote variables
@rochoa
rochoa / README.md
Last active June 21, 2022 18:42
CARTO Node.js code test

CARTO Node.js code test

Introduction

At CARTO, among other things, we render maps, just check this example of Map with countries and USA states.

In order to limit the scope of the challenge, we are gonna use Mapnik and Node.js. Within this repository, we are providing all the pieces you need to reproduce that map. Well, all pieces except the map tile server.

An example of how to create an image with Mapnik:

@aparrish
aparrish / index.md
Last active May 6, 2023 14:29
Getting credentials for the Mastodon API with Mastodon.py. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/

Getting credentials for the Mastodon API with Mastodon.py, step by step

Making a bot? Making a bot in Python? Making a bot in Python that uses the Mastodon API? If so, chances are you need to get some credentials. Here's how I did it!

(The following tutorial uses Python 2.7, but if you're using Python 3+ everything should work substantially the same.)

Mastodon.py authentication

I just started using it, but it looks like Mastodon.py is a pretty great library for working with the Mastodon API! However, all of the authentication examples use static files to store credentials, which I don't like—I'm afraid I'll accidentally push them to Github. I like to keep my authentication as close to the actual command that runs the program as possible, so usually I pass them on the command line to the script running my bot. To do this, I need to get the appropriate credentials on their own, as separate strings that I can cut and paste.

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.