Skip to content

Instantly share code, notes, and snippets.

View TSMMark's full-sized avatar
🐶

Mark Allen TSMMark

🐶
View GitHub Profile
@TSMMark
TSMMark / delete_local_branches.sh
Last active January 12, 2025 23:16
Delete local branches that don't exist on remote/origin !USE AT YOUR OWN RISK!
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -r -n 1 git branch -D
@TSMMark
TSMMark / main.js
Created May 4, 2016 15:19
Chloe's javascript closure
function SecretHuman (name) {
this.getName = function () {
return name
}
}
var person = new SecretHuman("Chloe")
console.log("My name is " + person.getName()) // => My name is Chloe
@TSMMark
TSMMark / pre-push
Created September 9, 2016 18:58
Prevent pushing to master in your git project!
# PUT THIS IN .git/hooks/pre-push IN YOUR PROJECT.
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
push_command=$(ps -ocommand= -p $PPID)
if [ $current_branch = $protected_branch ] || [[ $push_command =~ $protected_branch ]]
then
read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@TSMMark
TSMMark / .zshrc
Last active March 30, 2018 14:29
ZSHRC - zsh profile
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/mark/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="avit"
@TSMMark
TSMMark / clear-peer-deps.js
Created June 4, 2018 20:45
clear-peer-deps - remove peerDependency records from node_modules/* recursively
const fs = require('fs')
function replaceInFile ({ file, pattern, replacement }) {
fs.readFile(file, 'utf8', (err, data) => {
if (err) {
return console.log(err)
}
const result = data.replace(pattern, replacement)
@TSMMark
TSMMark / rake_utils.rb
Created December 4, 2018 05:01
Load rakefile once only
module RakeUtils
class << self
# Load the rakefile, unless it's already been loaded.
def load_rakefile
@load_rakefile ||= begin
load "#{PROJECT_ROOT_PATH}/Rakefile"
true
@TSMMark
TSMMark / cloudSettings
Last active January 7, 2025 16:00 — forked from StevePotter/cloudSettings
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-09-14T17:18:10.569Z","extensionVersion":"v3.4.3"}
@TSMMark
TSMMark / useSelectedItems.js
Last active July 26, 2019 04:29
useSelectedItems
// Default use:
const [selectedMedias, addId, removeId] = useSelectedItems(medias)
// Example of how to select an item
map(medias, ({ id, title }) => <a onClick={() => addId(id)}>{ id } { title }</a>)
// Example of how to deselect an item
map(selectedMedias, ({ id, title }) => <a onClick={() => removeId(id)}>{ id } { title } is selected!</a>)
@TSMMark
TSMMark / create-post.ts
Last active December 9, 2020 20:36
next.js netlify aws lambda higher order function composition handler middleware
export const handler: Handler = compose(
httpRespond(),
httpMethod('POST'),
)(async ({ body }: APIGatewayEvent) => ({
post: await createPost(JSON.parse(body))
}))
/*
Recently wrote some Next.js/Netlify functions to run in AWS Lambdas.