Skip to content

Instantly share code, notes, and snippets.

View niall-byrne's full-sized avatar
🎶

Niall Byrne niall-byrne

🎶
View GitHub Profile
@felipemeamaral
felipemeamaral / install-go-using-asdf-for-vscode-on-macos.md
Last active April 12, 2024 17:03
Install Go using asdf on macOS

Install Go using asdf for Visual Studio Code on macOS

I had a lot of issues trying to install Golang on macOS using asdf package manager to develop on Visual Studio Code.

So here's the steps needed to setup it properly:

Open Terminal and install asdf with this command:

You have to install Homebrew before running the installation command.

@sandinosaso
sandinosaso / App.jsx
Created June 12, 2021 07:17
Sunburst Chart Using D3 and React
import React from 'react';
import Sunburst from './sunburst';
import data from './data';
const App = () => {
return <Sunburst
data={chartData.data}
keyId="Sunburst"
width={600}
@progrium
progrium / README.md
Last active April 7, 2024 21:42
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • In general, binaries built just for x86 architecture will automatically be run in x86 mode
  • You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
  • You can force command-line apps by prefixing with arch -x86_64, for example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

# Instructions for fresh install
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
# reboot
$ source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
$ echo 'export NIX_PATH=darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH' | tee -a ~/.zshrc
$ echo 'source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh' | tee -a ~/.zshrc
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
@undergroundwires
undergroundwires / rename-all-tags.sh
Created May 23, 2020 20:35
Rename all tags in GIT repository from "v.." (e.g. "v1.0.0" to without "v" e.g. "1.0.0")
#!/usr/bin/env bash
push_tag() {
local tag="$1"
echo "Pushing $tag"
git push origin "$tag"
}
delete_tag() {
local tag="$1"
@therefromhere
therefromhere / firestore_emulator.py
Last active January 17, 2022 19:45
OBSOLETE, see comment below ||| Connection to the Firestore emulator in python, since it wasn't at that time supported by the official SDK, see https://github.com/googleapis/google-cloud-python/issues/7500
import os
from unittest import mock
import grpc
from google.auth.credentials import Credentials
from google.cloud import firestore
from google.cloud.firestore_v1.gapic import firestore_client
from google.cloud.firestore_v1.gapic.transports import firestore_grpc_transport
@pavelpy
pavelpy / lru_cache_for_class_decorator.py
Last active April 11, 2024 08:57
python functools lru_cache with class methods
# origin: https://stackoverflow.com/questions/33672412/python-functools-lru-cache-with-class-methods-release-object
import functools
import weakref
def memoized_method(*lru_args, **lru_kwargs):
def decorator(func):
@functools.wraps(func)
def wrapped_func(self, *args, **kwargs):
# We're storing the wrapped method inside the instance. If we had
# a strong reference to self the instance would never die.
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 24, 2024 08:27
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@dpapathanasiou
dpapathanasiou / trie.py
Last active April 16, 2022 09:47
Ternary Search Tree in python
#!/usr/bin/env python
"""
A ternary search tree implementation, inspired by:
http://www.drdobbs.com/database/ternary-search-trees/184410528 and
https://lukaszwrobel.pl/blog/ternary-search-tree/
https://github.com/djtrack16/tst/blob/master/ternarysearchtree.py
"""
@sk22
sk22 / lastfm-remove-duplicates.js
Last active January 13, 2024 16:26
Last.fm duplicate scrobble deleter
var elements = Array.from(document.querySelectorAll('.js-link-block'))
elements.map(function (element) {
var nameElement = element.querySelector('.chartlist-name')
return nameElement && nameElement.textContent.replace(/\s+/g, ' ').trim()
}).forEach(function (name, i, names) {
if (name !== names[i + 1]) return
var deleteButton = elements[i].querySelector('[data-ajax-form-sets-state="deleted"]')
if (deleteButton) deleteButton.click()
location.reload()
})