Skip to content

Instantly share code, notes, and snippets.

@fnicastri
fnicastri / configparser_to_dataclasses.py
Created October 9, 2024 07:15 — forked from tux-00/configparser_to_dataclasses.py
Converts python config parser to dataclasses (easier access)
import configparser
from dataclasses import dataclass
@dataclass
class Sections:
raw_sections: dict
def __post_init__(self):
for section_key, section_value in self.raw_sections.items():
@fnicastri
fnicastri / JSONB.go
Created October 1, 2024 17:37 — forked from mraaroncruz/JSONB.go
JSONB for postgres in Golang
// Found in this issue thread https://github.com/jinzhu/gorm/issues/516#issuecomment-109055198
// License unknown
//
//
// Postgres' JSONB type. It's a byte array of already encoded JSON (like json.RawMessage)
// which also saves itself correctly to PG's jsonb type. It would probably also work on
// PG json types.
type JSONB []byte
func (j JSONB) Value() (driver.Value, error) {
@fnicastri
fnicastri / README.md
Created September 25, 2024 08:26 — forked from clhenrick/README.md
PostgreSQL & PostGIS cheatsheet (a work in progress)
@fnicastri
fnicastri / application.ex
Created April 30, 2023 08:33 — forked from cblavier/application.ex
Cowboy 2.5 proxy, used to bind a single port (on Heroku) for umbrella Phoenix applications. It supports HTTPS and websockets properly.
defmodule MasterProxy.Application do
alias MyApp.Endpoint, as: MyAppEndpoint
alias MyApp.UserSocket, as: MyAppUserSocket
alias MyOtherApp.Endpoint, as: MyOtherAppEndpoint
alias MyOtherApp.UserSocket, as: MyOtherAppUserSocket
alias Phoenix.LiveReloader.Socket, as: LiveReloadSocket
alias Plug.Cowboy
@fnicastri
fnicastri / scroll_view_height.dart
Created March 27, 2023 18:02 — forked from slightfoot/scroll_view_height.dart
ScrollView With Height for Flutter. Simple ScrollView with its content having a minimum height of the ScrollView's parent. This allows you to space out your components inside your ScrollView to fit the avaliable space and not have them "squish up" when the soft keyboard (IME) appears.
class ScrollViewWithHeight extends StatelessWidget {
final Widget child;
const ScrollViewWithHeight({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
return new SingleChildScrollView(
child: new ConstrainedBox(
@fnicastri
fnicastri / subtrees.sh
Created February 16, 2023 08:24 — forked from Nikita240/subtrees.sh
Convert git submodules to git subtrees
#!/bin/bash -x
# This script will convert all your git submodules into git subtrees.
# This script ensures that your new subtrees point to the same commits as the
# old submodules did, unlike most other scripts that do this.
# THIS SCRIPT MUST BE PLACED OUTSIDE OF YOUR REPOSITORY!!!!!!!!!!
# Otherwise, the script will interfere with the git commits (unless you add it to .gitignore).
# Save the script in your home directory as `~/subtrees.sh`
# `cd` into your repository
# Run `~/subtrees.sh`
# Enjoy!
@fnicastri
fnicastri / App Icon Template.svg
Created February 15, 2023 19:26 — forked from thecodewarrior/App Icon Template.svg
An SVG template for creating macOS app icons, including guides and the standard drop shadow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fnicastri
fnicastri / backup_homedir.sh
Created May 20, 2022 10:50 — forked from artifactsauce/backup_homedir.sh
Backup script for Mac OS X home directory by rsync
#!/bin/sh
CMDNAME=`basename $0`
while getopts n OPT
do
case $OPT in
"n" ) DRY_RUN="--dry-run" ;;
* ) echo "Usage: $CMDNAME [-n]" 1>&2
exit 1 ;;
@fnicastri
fnicastri / subtitles-renamer.sh
Created February 23, 2022 10:40 — forked from colinux/subtitles-renamer.sh
Rename subtitles files according to tv shows names found in a directory
#!/bin/bash
# Renames subtitles files according to tv shows names found in a directory
# Acceped syntaxes for season/episode are: 304, s3e04, s03e04, 3x04 (case insensitive)
#
# Usage:
# Put this gist somewhere in your $PATH, like /usr/local/bin/subtitles-renamer
# Chmod +x it
# cd ~/YourHolidaysTvShowsWithSubtitles
# subtitles-renamer
@fnicastri
fnicastri / brew-dnsmasq.md
Created February 1, 2022 22:45 — forked from davebarnwell/brew-dnsmasq.md
install dnsmasq with brew

Install dnsmasq and configure for *.dev.local domains

$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf

Reload configuration and clear cache

# Copy the daemon configuration file into place.
$ sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/

$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist