Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brigand
brigand / git.md
Created October 6, 2014 02:50
My Git Aliases

I use git a lot for work and other projects, so I invested the time in creating some high quality aliases that really work for me. These just go in your bash profile (~/.bash_profile or ~/.bashrc or ~/.profile depending on your OS).

I see a lot of people go overboard with aliases, and then end up not using them. They're meant to cover 95% of the commands I use, not 100%.

alias gcam='git commit -am'
alias gs='git status'
alias gplr='git pull --rebase'
alias gpsh='git push'
alias gpo='git push -u origin `git symbolic-ref --short HEAD`'
@brigand
brigand / nickname.md
Created March 9, 2016 07:45
Freenode Setting Up Your Nickname

What is the recommended way to set up my IRC nickname?

Please follow these steps to set up your nick and configure your client. Check off each step to make sure it's been done:

Select a permanent, master nickname. If the nickname you want is registered but has expired, just ask a staffer and in most cases, we will be happy to drop it for you.

Please avoid using the name of a community project or trademarked entity, to avoid conflicts. Write down your password and be sure to keep the sheet of paper in a safe place.

Register your IRC nick:

@brigand
brigand / AutoHotkeyTest.java
Created December 28, 2011 06:26
Using AutoHotkey in a Java program
// All depends can be found here: http://apps.aboutscript.com/jhk/JHK.zip
// Video: http://youtu.be/EX0iT0NTTjw
import com.eaio.nativecall.*;
public class AutoHotkeyTest {
private static IntCall exec;
public static void main(String[] args) {
System.out.println("Hello World");
@brigand
brigand / GDIpHelper.ahk
Created October 23, 2012 20:28
Helper Library for GDIp library Based On Tic's tutorial #1
JustTheBasics() {
global
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
@brigand
brigand / express-saga.md
Last active January 14, 2022 14:23
express-saga is a web framework based on express and the saga pattern (redux-saga's interpretation) – just an idea, let's see if it turns out decent :-)

This is an idea, the code doesn't exist

express-saga is a web framework based on express and the saga pattern (redux-saga's interpretation).

You can use all existing express middleware without issue, but often there are better alternatives in express-saga.

Most effects from redux-saga are available, along with new effects for web server development.

This library is designed with a heavy focus on unit-testability. You don't need module level mocks due to dependency injection. Your routers are pure functions, so you don't need to run a http server in tests.

async function getUser(id) {
const p1 = getUserProfile(id);
const p2 = getUserSettings(id);
return {
profile: await p1,
settings: await p2,
};
}
@brigand
brigand / .js
Last active August 4, 2021 00:17
class Peekable {
constructor(iter) {
this.iter = iter;
this.deck = [];
}
peek() {
if (!this.deck.length) {
this.deck = [this.iter.next()];
}
return this.deck[0];
import React, { useState } from "react";
import styled from "styled-components";
import { Button, Form } from 'semantic-ui-react'
const PatientDetails = () => {
const [details, setDetails] = useState({
name: "John Doe",
gender: "male",
age: 34,
referredBy: "self",
@brigand
brigand / fetchJson.js
Created July 3, 2021 21:15
fetchJson
// Based on: https://jsfiddle.net/t2g9ub43/1/
const fetchJson = async (url, { ...opts } = {}) => {
opts.headers = new Headers(opts.headers);
opts.headers.set('Accept', 'application/json');
return fetch(url, opts).then((resp) => {
const ct = resp.headers.get('content-type');
if (!ct || !ct.includes('application/json')) {
throw resp;
}
return resp.json().then((json) =>
@brigand
brigand / .rs
Last active June 25, 2021 03:56
ErrorMime::JavaScript => format!(
"{pre}{json};\nlet css = {css_json};\n{code}\n{close}",
json = get_json(),
pre = "{ let error_json = ",
close = "}",
code = indoc::indoc!(r#"
const h = (tag, {style, ...props}, ...children) => {
const element = Object.assign(document.createElement(tag), props);
Object.assign(element.style, style);
for (const child of children) {