Skip to content

Instantly share code, notes, and snippets.

View jwo's full-sized avatar

Jesse Wolgamott jwo

View GitHub Profile
@jwo
jwo / main-static.rs
Last active February 22, 2021 15:24
Simple read-write lock in Rust. main.rs uses local variables; main-static.rs uses lazy_static to create a rw lock on a static variable.
use std::sync::RwLock;
#[macro_use]
extern crate lazy_static;
lazy_static! {
static ref MODELS: RwLock<i32> = RwLock::new(0);
}
fn update_it(number: i32) {
println!("You wanted me to update to {}", number);
@jwo
jwo / Dockerfile
Created October 26, 2017 20:52
Node app which uses dockerode to run a simple test suite against a Git Repo.
FROM node:8
RUN npm install -g write-good
ADD clone-run.sh /tmp/clone-run.sh
@jwo
jwo / query.graphql
Last active November 26, 2020 15:11
GraphQL Example for GitHub API repo statuses on a pull request. We know before hand that it's "jwo/react-hover-image" and pull request number 4
{
repository(owner: "jwo", name:"react-hover-image"){
url
pullRequest(number: 4){
number
url
author {
avatarUrl
login
resourcePath
@jwo
jwo / query.graphql
Last active May 31, 2021 20:53
GraphQL example: current user's 100 most current public repos
{
viewer {
repositories(privacy: PUBLIC, first: 3, orderBy: {field: PUSHED_AT, direction: DESC}) {
nodes {
nameWithOwner
url
}
}
}
}
@jwo
jwo / index.js
Created October 26, 2017 20:24
Simple way to sign in with github for oAuth in Node/Express
const express = require("express")
const app = express()
var passport = require("passport")
var session = require("express-session")
var GitHubStrategy = require("passport-github2").Strategy
const GITHUB_CLIENT_ID = "your-client-id-here" // or get from process.env.GITHUB_CLIENT_ID
const GITHUB_CLIENT_SECRET = "your-client-secret-here" // or get from process.env.GITHUB_CLIENT_SECRET
const GITHUB_CALLBACK_URL = "http://localhost:5000/auth/github/callback" // or get from process.env.GITHUB_CALLBACK_URL
@jwo
jwo / map.js
Last active March 31, 2022 10:41
React google maps with multiple markers, only one info window
import React, { Component } from "react"
import { compose } from "recompose"
import {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
InfoWindow
} from "react-google-maps"
@jwo
jwo / app.js
Created July 10, 2017 14:40
Simple example for testing an HTML endpoint in node with supertest and chai. Most examples only test API endpoints it seems.
const express = require("express");
const mustache = require("mustache-express");
const bodyParser = require("body-parser");
const app = express();
// Rest of the stuff here
// DONT FORGET THIS
module.exports = app;
@jwo
jwo / game.js
Created July 6, 2017 16:21
sample schema for mongoose
const mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
mongoose.connect('mongodb://localhost:27017/eighties');
const gameSchema = new mongoose.Schema({
name: {type: String, required: true},
imageUrl: {type: String, required: true},
tags: [String],
year: {type: Number, required: true},
link: {type: String, required: true}
@jwo
jwo / index.html
Created June 14, 2017 16:08
Fetch data from star wars api and display
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
.character {
display: flex;
width: 550px;
@jwo
jwo / spoon.js
Created June 7, 2017 16:15
Such a great super great awesome example of nested for loops
function properCase(sentence){
const words = sentence.split(' ');
let newWords = []
// Start the big spoon
for(let i = 0; i < words.length; i++){
const word = words[i];