Skip to content

Instantly share code, notes, and snippets.

@jseed
jseed / git-sub-commands.sh
Last active June 23, 2020 20:25
Defining custom sub commands, git example
#!/bin/bash
## Custom git commands
unset -f git > /dev/null 2>&1 # Remove custom function if already set (i.e. if `reload` is called)
GIT=$(which git) # Get path to original git executable
git() {
ERROR=1
// useApiData.js - general api data loading hook
import { useEffect, useState } from 'react';
import { apiFetch } from '../services/BaseApiService';
export default function useApiData(initialState, endpoint) {
const [loading, setLoading] = useState(false);
const [data, setData] = useState(initialState);
useEffect(() => {
setLoading(true);
@jseed
jseed / useCameraPermissions.js
Last active December 1, 2019 04:29
react-native context camera permissions hook
// PermissionsContext.js
import React, { createContext, useState } from 'react';
const PermissionsContext = createContext();
function PermissionsProvider({ children }) {
const [hasCameraPermissions, setHasCameraPermissions] = useState(null);
return (
<PermissionsContext.Provider value={[hasCameraPermissions, setHasCameraPermissions]}>
@jseed
jseed / Jenkins Branch Parameter
Created June 19, 2017 15:14
Groovy script for dynamically listing git repository branches as a jenkins build parameter using the extended choice parameter plugin
/*
* Variable bindings:
* user - credentials plugin user
* url - git repository url (.git)
*/
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import jenkins.model.Jenkins
@jseed
jseed / gist:5d022570ea52ee09a8f43913214496f1
Last active February 7, 2024 10:01
PowerShell command to delete all branches except master
git checkout master; git branch -D @(git branch | select-string -NotMatch "master" | Foreach {$_.Line.Trim()})