Instantly share code, notes, and snippets.

View add-label.sh
#!/bin/bash
# This program adds one or more labels to a GitHub issue/PR
username=
owner=
repo=
issue_or_pr_number=
curl -s https://api.github.com/repos/$owner/$repo/issues/$issue_or_pr_number/labels \
View index.js
// Transforms an array into a sentence.
// Example:
// toSentence(['apples', 'oranges', 'melons']);
// >> "apples, oranges and melons."
export function toSentence(arr) {
if (arr.length === 0) return '';
return arr.length > 1
? `${arr.slice(0, arr.length - 1).join(', ')} and ${arr.slice(-1)}.`
: `${arr[0]}.`;
View debugging.scss
* {
background-color: rgba(0,0,0,.1);
+ * {
background-color: rgba(255,0,0,.1);
+ * {
background-color: rgba(0,255,0,.1);
+ * {
View index.js
// Converts 'foo-bar' to 'fooBar'
// Credits: https://stackoverflow.com/a/6661012
export function camelize(str) {
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
}
function camelizeKeys(obj) {
return Object.assign(...Object.entries(obj).map(
([key, val]) => ({ [camelize(key)]: val })
View test.js
// Override console.error to run tests
const _console_error = console.error;
console.error = function (msg) {
if (/^Warning: Failed prop type:/.test(msg)) {
it('should pass PropType validation', () => {
throw new AssertionError(msg);
});
}
// Call the real console.error
return _console_error.apply(console, arguments);
View main.js
// Converts 'foo-bar' to 'fooBar'
// Credits: https://stackoverflow.com/a/6661012
export function camelize(str) {
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
}
// Converts 'fooBar' to 'foo-bar'
// Credits: https://gist.github.com/youssman/745578062609e8acac9f
export function parameterize(str) {
View open_pr.fish
# fill the dots with proper information
function open_pr
set commit_info (git log -1 --pretty=%B)
set title (echo $commit_info | sed -n '1p')
set description (echo $commit_info | tail -n +3 | sed -E ':a;N;$!ba;s/\r{0,1}\n/ \\n/g')
set source_branch (git rev-parse --abbrev-ref HEAD)
set destination_branch develop
set repo_full_name "foo/bar"
set reviewers "[ { \"username\": \"someusername\" }, ... ]"
View add.mips
.text
main:
li $t1, 1 # load immediate value 1 into $t1
add $t0, $t1, 2 # $t1 + 2 and put result into $t0
li $v0, 10 # 10 is the the exit syscall num
syscall
View example.erl
sum(L) -> sum(L,0).
sum([], Total) -> Total;
sum([H|T], Total) -> sum(T, H+Total).
View gpg.md

GPG Getting Started

  1. Check if you have gpg keys

     gpg --list-secret-keys --keyid-format LONG
    
  2. Import your pub/sec keypair

     gpg --import path/to/pub-key.asc