Skip to content

Instantly share code, notes, and snippets.

@naoty
naoty / position.rb
Last active May 14, 2024 12:44
ある緯度経度で指定された地点からある距離と方向に移動した後の緯度経度を計算する
here = Position.new(lat_A, lng_B)
# 90度方向に100m移動したあとの地点
there = here.move(distance: 100, heading: 90)
@ayoubzulfiqar
ayoubzulfiqar / folder_structure.md
Created September 5, 2023 06:12
The Folder Structure for Every Golang Project

Go - The Ultimate Folder Structure

Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:

project-root/
    ├── cmd/
    │   ├── your-app-name/
    │   │   ├── main.go         # Application entry point
    │   │   └── ...             # Other application-specific files
@hoangsonww
hoangsonww / Blockchain.py
Created April 8, 2024 04:05
A basic blockchain structure in Python with proof-of-work consensus, transaction handling, and wallet functionalities.
import hashlib
import json
from time import time
import binascii
from collections import OrderedDict
from uuid import uuid4
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
from cryptography.exceptions import InvalidSignature
@stephenmwilkins
stephenmwilkins / british_english.py
Created May 14, 2024 06:12
Python decorator enabling use of British English named arguments
def enable_british_english(func):
"""
A simple decorator allowing users to provide British english
arguments to functions and methods.
Example:
@enable_british_english
def favourite(color=None):
print(f"my favourite colour is {color}")
@porjo
porjo / dump_route53_records.md
Last active May 14, 2024 12:40
Export route53 records to CSV

Retrieve hosted zones with aws route53 list-hosted-zones then enter the zone Id below:

aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/xxxxxxxxxxx" | \
   jq -r '.ResourceRecordSets[] | [.Name, .Type, (.ResourceRecords[]? | .Value), .AliasTarget.DNSName?]  | @tsv'
@Mearman
Mearman / Obsidian Snippets
Last active May 14, 2024 12:39
Obsidian Snippets
A collection of snippets
@iAugur
iAugur / ansible-add-string-to-line.yml
Last active May 14, 2024 12:37
Ansible: Add a String to an existing line in a file
# Adapted from solution provided by http://stackoverflow.com/users/57719/chin-huang http://stackoverflow.com/a/31465939/348868
# Scenario: You want to add a group to the list of the AllowGroups in ssh_config
# before:
# AllowGroups Group1
# After:
# AllowGroups Group1 Group2
- name: Add Group to AllowGroups
replace:
backup: yes
@poing
poing / laravel_facades.md
Last active May 14, 2024 12:36
Laravel Facades

Understanding Facades in Laravel

What's a Facade?

The Laravel explination, shown below is confusing.

Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades which provide access to almost all of Laravel's features. Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

Many examples use Cache::get('key') to demonstrate how a Facade works. Comparing the following code to the utility that a Facade provides.

@ynott
ynott / multipass-on-bridged-network.md
Last active May 14, 2024 12:35
Instructions for running multipass on a bridge network

1. Environmental information

  • OS: Ubuntu 20.04.2 LTS (GNU/Linux 5.8.0-59-generic x86_64)
  • Network: 192.168.xxx.0/24
  • Ubuntu multipass host machine IP: 192.168.xxx.yyy(static IP)
  • NIC: enp2s0(bridge host NIC)
  • Bridge NIC:br0

2. Prerequisites

@AIWintermuteAI
AIWintermuteAI / test_transcribe.py
Created December 18, 2023 08:43
Python file to compare the inference times between whisper.cpp Python bindings and faster-whisper
import argparse
import whispercpp as w
from faster_whisper import WhisperModel, decode_audio
import time
from collections.abc import Iterator
from contextlib import contextmanager
@contextmanager
def time_it() -> Iterator[None]: