Skip to content

Instantly share code, notes, and snippets.

View abbott's full-sized avatar
🎯
Focusing

Bruce Abbott abbott

🎯
Focusing
View GitHub Profile
@abbott
abbott / cleanup_swap.md
Created December 10, 2023 23:35 — forked from anildigital/cleanup_swap.md
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@abbott
abbott / smbmount
Created February 20, 2023 04:05 — forked from Dalesjo/smbmount
Script to safetly mount a smb share.
#!/bin/bash
SMGUID=0
SMBGID=0
while getopts 'd:s:u:p:U:G:' flag; do
case "${flag}" in
d) DIRECTORY="${OPTARG}" ;;
s) SHARE="${OPTARG}" ;;
u) USERNAME="${OPTARG}" ;;
ii samba 2:4.10.9+karoshi-1~linuxschools1+bionic1 amd64 SMB/CIFS file, print and login server for Unix
ii samba-common 2:4.10.9+karoshi-1~linuxschools1+bionic1 all common files used by both the Samba server and client
ii samba-common-bin 2:4.10.9+karoshi-1~linuxschools1+bionic1 amd64 Samba common files used by both the server and the client
ii samba-dbg 2:4.10.9+karoshi-1~linuxschools1+bionic1 amd64 Samba debugging symbols
ii samba-dsdb-modules 2:4.10.9+karoshi-1~linuxschools1+bionic1 amd64 Samba Directory Services Database
ii samba-libs:amd64 2:4.10.9+karoshi-1~linuxschools1+bionic1 amd64 Samba core libraries
ii samba-vfs-modules 2:4.10.9+karoshi-1~linuxschools1+bionic1 amd64 Samba Virtual FileSystem plugins
@abbott
abbott / href.js
Last active January 21, 2024 16:40
Google Analytics event wrapper in React.js (compatible w/Next.js next/link)
import { forwardRef, useEffect, memo } from 'react';
import * as useGA from '@lib/useGA';
const Href = forwardRef((props, ref) => {
let element;
const {
onClick,
onMouseOver,
@abbott
abbott / global-state.js
Last active January 21, 2024 03:23
Global state provider using Context API in React.js
import { createContext, useContext, useMemo } from 'react';
import { useLocalStorage } from './local-storage';
import { getOs, getBrowser } from '@lib/utils';
import { SITE } from '@data/constants';
export const GlobalContext = createContext();
const date = new Date().toISOString();
const os = getOs().toLowerCase();
const browser = getBrowser().toLowerCase();
@abbott
abbott / head-meta.js
Last active July 31, 2020 18:00
Meta tag and SEO for Next.js next/head component
import Head from 'next/head';
import { removeEmojiUnicode } from '@lib/utils';
import { ENTITY, SOCIAL, SITE, CONTENT } from '@lib/constants';
export default function HeadMeta ({ id }) {
const META = CONTENT[id];
const title = (META.TITLE !== 'Hi, I\'m Bruce'
? removeEmojiUnicode(META.TITLE) + ' - '
: '') + SITE.NAME;