Skip to content

Instantly share code, notes, and snippets.

@rgstephens
rgstephens / schema.js
Created July 31, 2017 02:55
Sample Schema dev-blog.apollodata.com
import { makeExecutableSchema } from 'graphql-tools';
const typeDefs = `
type Author {
id: Int
firstName: String
lastName: String
posts: [Post]
}
type Post {
@rgstephens
rgstephens / index.js
Last active July 31, 2017 16:45
Sample Apollo-Server w/Express
import express from 'express';
import bodyParser from 'body-parser';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
import schema from './schema.js'
const PORT = 3000;
const app = express();
console.log('calling app.js');
// bodyParser is needed just for POST.
@rgstephens
rgstephens / package.json
Last active August 18, 2017 16:43
NativeStarterPro updated package.json with RN 0.46.4
{
"name": "StrapNativeStarter-Pro",
"version": "7.0.0",
"private": true,
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"postinstall": "remotedev-debugger",
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
@rgstephens
rgstephens / google_music_list.js
Last active August 23, 2017 01:07
List songs in Google Music Playlist
var allsongs = []
var outText = "";
var songsToText = function(style, csv, likedonly){
if (style === undefined){
console.log("style is undefined.");
return;
}
var csv = csv || false; // defaults to false
var likedonly = likedonly || false; // defaults to false
if (likedonly) {
@rgstephens
rgstephens / create_field.php
Created October 8, 2017 15:53
WordPress create field wp-cli script
<?php
$all_users = get_users();
foreach( $all_users as $user ) {
$women = get_user_meta($user->ID, 'women_golfing');
$men = get_user_meta($user->ID, 'men_golfing');
if ($men[0] == 'True' || $women[0] == 'True') {
add_user_meta($user->ID, 'course_updates', "True");
WP_CLI::success( "user: " . $user->ID . ", men/women: " . $men[0] . " / " . $women[0]);
} else {
WP_CLI::warning( "user: " . $user->ID . ", men/women: " . $men[0] . " / " . $women[0]);
@rgstephens
rgstephens / client.yaml
Last active October 19, 2017 01:31
Client Management REST API Definition
swagger: "2.0"
info:
description: "This is a sample client management API. The YAML definition for this API can be found at [https://gist.github.com/358ef6d256a69084357e139f8c7db19b.git](https://gist.github.com/358ef6d256a69084357e139f8c7db19b.git)"
version: "0.1.0"
title: "Client API"
contact:
email: "[email protected]"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
@rgstephens
rgstephens / client.json
Created October 19, 2017 03:25
Client API Swagger JSON Definition
{
"swagger": "2.0",
"info": {
"description": "This is a sample client management API. The YAML definition for this API can be found at [https://gist.github.com/358ef6d256a69084357e139f8c7db19b.git](https://gist.github.com/358ef6d256a69084357e139f8c7db19b.git)",
"version": "0.1.0",
"title": "Client API",
"contact": {
"email": "[email protected]"
},
"license": {
@rgstephens
rgstephens / makecerts.sh
Last active November 20, 2017 01:33
Make Self Signed Certificate
#!/bin/bash
# https://stackoverflow.com/questions/19665863/how-do-i-use-a-self-signed-certificate-for-a-https-node-js-server
FQDN=$1
KEYDIR=keys
# make directories to work from
#mkdir -p server/ client/ all/
mkdir -p $KEYDIR
# Create your very own Root Certificate Authority
@rgstephens
rgstephens / pi_setup.sh
Last active May 18, 2021 12:49
Raspberry Pi Setup Script
#!/bin/bash
# Whiptail examples - http://xmodulo.com/create-dialog-boxes-interactive-shell-script.html
oldhostname=$(hostname)
newhostname=$(whiptail --title "Hostname" --inputbox "Change hostname?" 10 60 $oldhostname 3>&1 1>&2 2>&3)
export exitstatus=$?
if [ $exitstatus != 0 ]; then
exit $exitstatus
fi
toemail=$(whiptail --title "gmail" --inputbox "Enter gmail (w/o @gmail.com) address to notify when script is done" 10 60 3>&1 1>&2 2>&3)
export exitstatus=$?
@rgstephens
rgstephens / Raspbian Setup & Eddygrid Install
Last active February 12, 2018 01:36
pi_eddygrid_setup.sh
#!/bin/bash
set -x
sudo cp /usr/share/zoneinfo/US/Pacific /etc/localtime
sudo apt-get remove -y wolfram-engine sonic-pi nodejs-legacy nodejs nodered
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y emacs git htop dnsutils
git clone https://github.com/sdesalas/node-pi-zero.git
cd node-pi-zero
chmod +x install-node-v4.4.1.sh