Skip to content

Instantly share code, notes, and snippets.

@socketbox
socketbox / worktree.md
Last active December 12, 2025 17:05
Start a new git worktree from an existing branch other than the default

Starting out

Run these commands in a directory devoted to your project:

mkdir project_foo
cd project_foo
git clone --bare [email protected]:yourorg/project_foo.git .bare
echo "gitdir: ./.bare" > .git

Now edit .bare/config, adding fetch = +refs/heads/*:refs/remotes/origin/* below [remote "origin"]

@kepano
kepano / obsidian-web-clipper.js
Last active December 19, 2025 02:32
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/[email protected]?module'), import('https://unpkg.com/@tehshrike/[email protected]'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@marcogrcr
marcogrcr / sigv4_using_http_client.py
Last active August 29, 2025 10:27
Send request with SigV4 in python using boto3
from boto3.session import Session
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
from botocore.credentials import Credentials
from http.client import HTTPConnection, HTTPSConnection
import json
import os
from urllib.parse import urlparse
def sigv4_request(
@abelcallejo
abelcallejo / README.md
Last active May 27, 2025 21:46
Installing GDAL 3.2.1 on Amazon Linux 2

Installing GDAL 3.2.1 on Amazon Linux 2

gdal linux yum

As of this day, this is probably the only and fastest way of installing it.

Package requirements

Based from the GDAL and PROJ build requirements, here is the full list of required packages to install:

@mxdevmanuel
mxdevmanuel / dart.ctags
Created April 25, 2020 17:04
Dart ctags (tested with universal-ctags) WIP
--langdef=dart
--langmap=dart:.dart
--regex-dart=/^[ \t]*enum[ \t]+([_A-Za-z][_0-9A-Za-z]*)/\1/e,enum/
--regex-dart=/^[ \t]*class[ \t]+([_A-Za-z][_0-9A-Za-z]*)/\1/c,class/
--regex-dart=/^[ \t]*var[ \t]+([_A-Za-z][_0-9A-Za-z]*)/\1/v,variable/
@Meorawr
Meorawr / async.lua
Last active September 8, 2024 20:17
Lua 5.1 Async/Await
#!/usr/bin/lua5.1
--- Async/Await for Lua 5.1
-- This script implements async/await functions for Lua, allowing tasks to
-- be queued and scheduled independently.
--
-- This is just an example and has a bunch of issues, isn't tested, isn't
-- even actually used anywhere; I basically just got bored and had one of
-- those "what if?" type ideas 6 hours ago.
local co_create = coroutine.create
@jeff3dx
jeff3dx / d3-in-react.js
Last active October 27, 2022 09:24
D3 in React with Hooks
import React, { useRef, useEffect } from 'react';
import * as d3 from 'd3';
interface IProps {
data?: number[];
}
/* Component */
export const MyD3Component = (props: IProps) => {
/* The useRef Hook creates a variable that "holds on" to a value across rendering
@jukben
jukben / CachedLayer.js
Last active December 12, 2022 20:07
Custom Layer for react-leafleat with naive cache mechanism
import { withLeaflet, GridLayer } from "react-leaflet";
import L from "leaflet";
class Grid extends GridLayer {
createLeafletElement() {
const { url, cacheName } = this.props;
const Layer = L.TileLayer.extend({
createTile: (coords, done) => {
const { x, y, z } = coords;
@LegoStormtroopr
LegoStormtroopr / boto_auth_requests.py
Created August 31, 2017 23:06
Connecting Django/Haystack to AWS ElasticSearch using IAM rotating credentials
import boto3
import os
import requests
from botocore.auth import SigV4Auth
from requests_aws4auth import AWS4Auth
from elasticsearch import RequestsHttpConnection
class AWSRequestsHttpConnection(RequestsHttpConnection):
# Auto list fields from django models - from https://djangosnippets.org/snippets/2533/#c5977
import inspect
from django.utils.html import strip_tags
from django.utils.encoding import force_text
def process_docstring(app, what, name, obj, options, lines):
# This causes import errors if left outside the function
from django.db import models