Skip to content

Instantly share code, notes, and snippets.

View jwo's full-sized avatar

Jesse Wolgamott jwo

View GitHub Profile
@jwo
jwo / mysql.database.yml
Last active March 28, 2024 15:32
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
@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 / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@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 / 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
Last active February 14, 2022 13:32
Notes before I blog about it: how-to-use-actioncable-and-npm-action-cable
import React, { Component } from 'react';
import ActionCable from 'actioncable';
class App extends Component {
componentWillMount() {
var cable = ActionCable.createConsumer('ws://localhost:3000/cable')
@jwo
jwo / secret_controller.rb
Created November 5, 2013 17:57
Devise testing controllers - minitest / rails4
class SecretController < ApplicationController
before_filter :authenticate_user!
def show
end
end
@jwo
jwo / nginx.conf
Created January 2, 2012 20:03
nginx config for unicorn
# you generally only need one nginx worker unless you're serving
# large amounts of static files which require blocking disk reads
worker_processes 1;
user nobody nogroup; # for systems with a "nogroup"
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
@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 / 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);