Skip to content

Instantly share code, notes, and snippets.

@ograycode
ograycode / simpleStoreExample.js
Created May 17, 2019 12:40
A super simple implementation of a psuedo-flux pattern.
import React, { Component, Fragment } from 'react';
const connect = (Wrapped, store) => {
return class extends Component {
constructor(props) {
super(props);
this.state = { store };
}
dispatch(name, data) {
@ograycode
ograycode / matching_configs.rb
Created May 4, 2017 20:51
Find matching configs between heroku apps
=begin
Usage: ruby matching_configs <app1> <app2>
=end
require 'json'
first_app_name = ARGV[0]
second_app_name = ARGV[1]
puts "Finding matches for #{first_app_name} -> #{second_app_name}"
@ograycode
ograycode / Dockerfile
Last active April 12, 2016 12:09
django microservice example
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
8.4. Timing events
------------------
Timers provide a great help in troubleshooting network problems. All values are
reported in milliseconds (ms). These timers should be used in conjunction with
the session termination flags. In TCP mode with "option tcplog" set on the
frontend, 3 control points are reported under the form "Tw/Tc/Tt", and in HTTP
mode, 5 control points are reported under the form "Tq/Tw/Tc/Tr/Tt" :
- Tq: total time to get the client request (HTTP mode only). It's the time
/*
* If the user writes both DISTINCT ON and ORDER BY, adopt the sorting
* semantics from ORDER BY items that match DISTINCT ON items, and also
* adopt their column sort order. We insist that the distinctClause and
* sortClause match, so throw error if we find the need to add any more
* distinctClause items after we've skipped an ORDER BY item that wasn't
* in DISTINCT ON.
*/
skipped_sortitem = false;
foreach(lc, sortClause)
@ograycode
ograycode / summary
Created August 20, 2013 00:15 — forked from phaedryx/summary
Original text here: http://www.heartmindcode.com/blog/2013/08/loyalty-and-layoffs/
@ograycode
ograycode / Application.scala
Last active December 20, 2015 14:38
Play 2.1.2 message passing in Akka. This is from the application controller. Half the imports here probably are not used.
package controllers
import akka.actor.Props
import akka.actor._
import akka.actor
import akka.pattern._
import akka.util._
import akka.event._
import scala.concurrent.Await
import scala.concurrent.Future
@ograycode
ograycode / image_generator.py
Created May 18, 2013 21:09
Quickly generate images containing your samples and your background images.
import Image
import os
import random
training_images = []
training_path = 'cropped'
background_images = []
background_path = 'background'
training_file = 'train'
@ograycode
ograycode / event-mongoose.js
Created November 11, 2012 16:18
Potential Mongoose Bug
var mongoose = require('mongoose');
var EventUser = new mongoose.Schema({
user_name: String,
attending: Boolean
});
var Comments = new mongoose.Schema({
date: Date,
text: String,
@ograycode
ograycode / RomanNumeralToNumber.cpp
Created October 10, 2012 02:36
Roman Numeral To Number Converter
#include "stdafx.h"
#include <string>
#include <iostream>
#include <map>
int romToNum(std::string rom);
bool ShouldSubtract(std::string rom, int position);
std::map<char, int> romNumMap;