Skip to content

Instantly share code, notes, and snippets.

View bahodge's full-sized avatar
🌈
exit vim by unplugging your monitors

Ben Hodge bahodge

🌈
exit vim by unplugging your monitors
View GitHub Profile
@bahodge
bahodge / take_database_snapshot.sh
Created November 4, 2019 17:52
Take a snapshot of your postgres database
#!/usr/bin/bash
# This script will take a snapshot of the database
# It will then gzip it
# It will save it in the 'storage' directory
# it will delete any old db snapshots > 7 days.
echo "===== Starting Snapshot ===="
formatted_date=`date +'%m%d%Y'`
formatted_time=`date +'%I%M%S'`
@bahodge
bahodge / CreateClientMutation.js
Created September 25, 2019 13:32
Creating a custom mutation return payload with Graphql-Rails
// An example mutation using react & gql
import gql from 'graphql-tag'
export default gql`
mutation CREATE_CLIENT($name: String!) {
createClient(name: $name) {
client {
id
}
@bahodge
bahodge / graphql_example.graphql
Last active September 26, 2019 16:32
Metaprogramming a policy type for graphql with rails
# graphql_example.graphql
# user query
query MY_USER_QUERY($id: ID!) {
user(id: $id) {
id
policy {
isAdmin
isCreator
...
@bahodge
bahodge / mix_format_script.sh
Created May 4, 2019 20:43
Find or Create .formatter.exs script that makes one in the current directory
#!/bin/sh
current=$(pwd)
formatter_file=".formatter.exs"
echo $current
if [ -e $current/"$formatter_file" ];
then
mix format
echo "Formatting Complete"
@bahodge
bahodge / js-statements-practice.js
Created March 1, 2018 02:33
JavaScript - Statements practice with solutions included.
//########### Cool guy statements ##########
//1.Declare 2 variables named {num1} and {num2} that are of type number. (Give them numerical values).
var num1 = 2;
var num2 = 5;
//2.Add num1 and num2 and display the result in the console. store the sum in a new variable called num3;
@bahodge
bahodge / ranged-power-table.java
Created February 28, 2018 16:57
A loop that builds a table in the console between a low and high user input number
Scanner scan = new Scanner(System.in);
boolean userCont;
String userAns;
do {
System.out.print("Enter your min value: ");
int userLow = scan.nextInt();
System.out.print("Enter your high value: ");
int userHigh = scan.nextInt();
System.out.println("number | squared | cubed");