Skip to content

Instantly share code, notes, and snippets.

@kepano
kepano / obsidian-web-clipper.js
Last active July 22, 2024 07:29
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/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).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 July 18, 2024 16:05
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 March 25, 2024 11:35
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:

@Meorawr
Meorawr / async.lua
Last active December 12, 2023 05:13
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
@mekza
mekza / betterthanboto.py
Last active September 29, 2023 17:40
Signed URLs and Signed Cookies for CloudFront in Python with boto
from boto.cloudfront.distribution import Distribution
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
import base64
class BetterThanBoto(Distribution):
def sign_rsa(self, message):
@viesti
viesti / filters.py
Created September 17, 2015 13:10
Ansible filter plugin to create rules fo ec2_group
def make_rules(hosts, ports, proto):
return [{"proto": proto,
"from_port": port,
"to_port": port,
"cidr_ip": host} for host in hosts for port in map(int, ports.split(","))]
class FilterModule(object):
def filters(self):
return {'make_rules': make_rules}