Skip to content

Instantly share code, notes, and snippets.

View danielpox's full-sized avatar

Daniel Hallgren danielpox

View GitHub Profile
import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"
@idriszmy
idriszmy / code.py
Last active February 27, 2024 13:24
Play MP3 files from SD card using Maker Pi Pico and CircuitPython
"""
Play MP3 files from SD card using Maker Pi Pico and CircuitPython
Maker Pi Pico
- https://my.cytron.io/p-maker-pi-pico
6W Stereo USB Powered 3.5mm Jack Speaker
- https://my.cytron.io/p-6w-stereo-usb-powered-3-5mm-jack-speaker-black
Dual 18650 Dual Output 3.3V and 5V USB Module (optional)
- https://my.cytron.io/c-lithium-ion-rechargeable-battery-and-charger
3.7V 2000mAh Li-Ion Battery
@kourge
kourge / jslike.code-snippets
Created March 3, 2021 23:20
a VS Code snippet for typing in JS imports module-first, like the order in Python
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
"Named import": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "from",
// by dave :)
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
@tigt
tigt / git-branch-to-favicon.js
Created March 18, 2020 21:10
Creates an SVG string that can be used as a favicon across different Git branches. Actually getting this into the browser is sadly project-specific.
const { execSync } = require('child_process')
const { createHash } = require('crypto')
const invertColor = require('invert-color')
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
const hash = createHash('sha256')
hash.update(branchName)
const color = '#' + hash.digest().toString('hex').substring(0, 6)
const invertedColor = invertColor(color, true)
{
"suggest.noselect": false,
"coc.preferences.formatOnSaveFiletypes": [
"javascript",
"typescript",
"typescriptreact",
"json",
"javascriptreact",
"typescript.tsx",
"graphql"
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@mattt
mattt / UIViewControllerPreview.swift
Last active October 7, 2024 06:51
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@lideo
lideo / gist:82fb863749f4efe1deb9ca146b1093e8
Created October 8, 2019 08:09
Exclude .DS_Store file from tar.gz
tar -zcv --exclude='.DS_Store' -f file.tar.gz folder/
@btxtiger
btxtiger / AesUtil.ts
Last active September 20, 2024 17:29 — forked from AndiDittrich/AesUtil.js
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
/**
* Cryptography Functions
*
* Forked from AndiDittrich/AesUtil.js
* https://gist.github.com/AndiDittrich/4629e7db04819244e843
*/
import crypto, { CipherGCM, CipherGCMTypes, DecipherGCM } from 'crypto';
import { Password } from './types';