Skip to content

Instantly share code, notes, and snippets.

View iheanyi's full-sized avatar
🪐
Working on databases @planetscale

Iheanyi Ekechukwu iheanyi

🪐
Working on databases @planetscale
View GitHub Profile
@mjackson
mjackson / WindowScrollTo.js
Last active January 16, 2017 02:11
Make window.scrollTo declarative using a <WindowScrollTo> React component
import React from 'react'
import warning from 'warning'
const { number, object } = React.PropTypes
const WindowScrollTo = React.createClass({
contextTypes: {
windowScrollTo: object
},
import React, { Component } from 'react';
import IPropTypes from 'react-immutable-proptypes';
import topojson from 'topojson';
import classNames from 'classnames';
import d3 from 'd3';
import { compose, contains, find, pluck, prop, propEq } from 'ramda';
import world110m from 'json!./out.json';
import states from 'json!./states.topojson';
@mbriggs
mbriggs / anonymous-gist.rb
Created January 17, 2016 00:51
my rails helper for webpack dev server, and compiled into public
def include_js(file)
@_js_includes ||= {}
@_js_includes[file] ||= begin
manifest_path = Rails.root.join('public', 'assets', 'manifest.json')
if File.exist?(manifest_path)
manifest = JSON.parse(File.read(manifest_path))
path = "/assets/#{manifest[file]}"
else
path = "http://127.0.0.1:8080/#{file}"
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@mlafeldt
mlafeldt / x.md
Last active October 30, 2019 00:13
Semantic monitoring, from Building Microservices

Service metrics

I would strongly suggest having your services expose basic metrics themselves. At a bare minimum, for a web service you should probably expose metrics like response times and error rates—vital if your server isn’t fronted by a web server that is doing this for you. But you should really go further. For example, our accounts service may want to expose the number of times customers view their past orders, or your web shop might want to capture how much money has been made during the last day.

Semantic Monitoring

We can try to work out if a service is healthy by, for example, deciding what a good CPU level is, or what makes for an acceptable response time. If our monitoring system detects that the actual values fall outside this safe level, we can trigger an alert— something that a tool like Nagios is more than capable of.

However, in many ways, these values are one step removed from what we actually want to track—namely, is the system working? The more complex the interactions

class Wizard extends React.Component {
// define what types I put on context
static childContextTypes = {
wizardState: React.PropTypes.object,
changeWizardState: React.PropTypes.func
}
constructor(props, context) {
super(props, context)
@clettenberg
clettenberg / github_api.rb
Created November 16, 2015 04:15
GitHub API Interactor
class GithubApi
attr_reader :token, :api_info, :code
attr_accessor :user
def initialize(code)
@code = code
@token = github.get_token(code).token
create_or_update
end
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var shared = require('./shared')
module.exports = {
devtool: 'inline-source-map',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
@jgautsch
jgautsch / App.js
Created July 29, 2015 04:54
Defining client routes for react-routes in ruby, so they can be checked both on the client and server
import $ from 'jquery';
import React from 'react';
import Router, { Route } from 'react-router';
import App from './components/App';
// Recursively builds the nested react components that represent the routes
var buildRoutes = (routesObj) => {
return routesObj.map((route) => {
if (!route.name || !route.path || !route.handler) {
console.error('route.name (:as), route.path, and route.handler must all be defined.');
@fivetanley
fivetanley / post-route.js
Last active August 29, 2015 14:25
yo iheanyi
import Ember from 'ember';
const {Promise} = Ember.RSVP;
export default Ember.Route.extend({
model() {
var slug = params.id;
return new Promise((resolve, reject) => {
$.getJSON(`/api/posts/${slug}`).then((payload) => {
let id = payload.post.id;