Skip to content

Instantly share code, notes, and snippets.

View ushu's full-sized avatar

Aurélien Noce ushu

View GitHub Profile
@ushu
ushu / commit-msg
Created January 6, 2016 10:18
Commit hooks to prepend jira tags to commits (using the name of the current branch)
#!/usr/bin/env ruby
# Avoid commiting when the commit message contains ONLY the JIRA tag
# Get the name of the current branch
current_branch = `git symbolic-ref --short HEAD`
# Check if we are on a JIRA branch
TAG_REGEX = /^([[:alpha:]]+)[-_](\d+)$/
if current_branch =~ TAG_REGEX
file_name = ARGV[0]
@ushu
ushu / init.coffee
Last active June 9, 2016 07:33
Atom Settings
# 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 ->
@ushu
ushu / hello_world.asm
Last active September 25, 2017 12:19
Hello World on NASM that runs on a Mac
; Basic Hello World that compiles on MacOS
; nasm -fmacho64 test.asm && cc test.o -Wl,-no_pie && ./a.out
global _main
extern _puts, _exit
section .text
_main:
; Saves the stack, not really useful here but will ensure the stack is 16 bits-aligned
@ushu
ushu / generate_app_json.rb
Created February 14, 2019 11:57
Generate a new app.json file for the current project
#!/usr/bin/env ruby
require 'json'
# Grab info from the heroku cli
info = JSON.load(`heroku info --json`)
env_variables = JSON.load(`heroku config --json`)
buildpacks = `heroku buildpacks`.lines[1..].map{ |l| { 'url' => l[3..].chop }}
addons = JSON.load(`heroku addons --json`).inject(Hash.new{ |h, k| h[k] = [] }) { |h, e|
name = e['addon_service']['name']
plan = e['plan']['name']
@ushu
ushu / useSafeState.ts
Last active April 24, 2020 19:24
A(nother) version of setState that won't raise an error when called on an unmounted component, TypeScript version
import {
useState,
Dispatch,
SetStateAction,
useRef,
useEffect,
useCallback,
} from "react"
function useSafeState<S = undefined>(