Skip to content

Instantly share code, notes, and snippets.

@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

@fnicastri
fnicastri / gist:ac81380666d9fbe18681e21bfab527ac
Created January 19, 2022 11:20 — forked from Luoyayu/gist:3c5f099dd1a453f049fced1df7bc7964
extract Xcode.xip to a customed volume
By default, when extracts the Xcode.zip,
macos will create tmp file in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/com.apple.AUHelperService`.
Sometimes, the /private has no ehough space to hold 19GB Xcode.app.
Thus we can create a soft link named `com.apple.AUHelperService` in the tmp dir.
Steps:
1. BACKUP `com.apple.AUHelperService` in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/` to `com.apple.AUHelperService_BACKUP`
2. mkdir named `com.apple.AUHelperService` wherever you have enough space,
3. ln -s /your/absolute/path/com.apple.AUHelperService /private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T
4. double click the Xcode.xip
Total allocated: 293.96 MB (3655849 objects)
Total retained: 13.50 MB (98432 objects)
allocated memory by gem
-----------------------------------
58.07 MB actionpack-6.0.3.2
57.97 MB activesupport-6.0.3.2
50.11 MB activemodel-6.0.3.2
48.96 MB activerecord-6.0.3.2
11.50 MB railties-6.0.3.2
@fnicastri
fnicastri / appify.sh
Created June 28, 2020 10:45 — forked from oubiwann/appify.sh
appify — create the simplest possible Mac app from a shell script (adds an application icon)
#!/usr/bin/env bash
VERSION=4.0.1
SCRIPT=`basename "$0"`
APPNAME="My App"
APPICONS="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns"
OSX_VERSION=`sw_vers -productVersion`
PWD=`pwd`
function usage {