Skip to content

Instantly share code, notes, and snippets.

View AndrewJHart's full-sized avatar
:electron:
Building react apps & micro-services

Andrew Hart AndrewJHart

:electron:
Building react apps & micro-services
View GitHub Profile
@AndrewJHart
AndrewJHart / Node-streams-demystified.md
Last active January 20, 2020 07:46 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@AndrewJHart
AndrewJHart / README.md
Created February 26, 2016 00:22 — forked from rduplain/README.md
Connect to MSSQL using FreeTDS / ODBC in Python.

Goal: Connect to MSSQL using FreeTDS / ODBC in Python.

Host: Ubuntu 11.10 x86_64

Install:

sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy

In /etc/odbcinst.ini:

@AndrewJHart
AndrewJHart / validate_uuid4.py
Created February 26, 2016 15:19 — forked from ShawnMilo/validate_uuid4.py
Validating a uuid4 with Python.
from uuid import UUID
def validate_uuid4(uuid_string):
"""
Validate that a UUID string is in
fact a valid uuid4.
Happily, the uuid module does the actual
checking for us.
class DynamicFieldsMixin(object):
"""
A serializer mixin that takes an additional `fields` argument that controls
which fields should be displayed.
Usage::
class MySerializer(serializers.HyperlinkedModelSerializer, DynamicFieldsMixin):
class Meta:
model = MyModel
@AndrewJHart
AndrewJHart / .env
Created March 18, 2016 20:06 — forked from allanlei/.env
Sample local Heroku/Django development environment using foreman
DATABASE_URL=postgres://USERNAME:[email protected]/DATABASE
MEMCACHE_SERVERS=127.0.0.1:11211
DJANGO_SETTINGS_MODULE=settings.development.local
@AndrewJHart
AndrewJHart / emitter.service.ts
Created February 11, 2017 09:56 — forked from sasxa/emitter.service.ts
Angular2 Communicating between sibling components
import {Injectable, EventEmitter} from 'angular2/core';
@Injectable()
export class EmitterService {
private static _emitters: { [ID: string]: EventEmitter<any> } = {};
static get(ID: string): EventEmitter<any> {
if (!this._emitters[ID])
this._emitters[ID] = new EventEmitter();
return this._emitters[ID];
@AndrewJHart
AndrewJHart / webpack.config.js
Created May 8, 2017 16:51 — forked from JaySpears/webpack.config.js
Webpack 2.0 Configuration with React Example
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:3000/',
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'app/index')
],
@AndrewJHart
AndrewJHart / remerge.py
Created October 17, 2017 18:42 — forked from mahmoud/remerge.py
Recursively merging dictionaries with boltons.iterutils.remap. Useful for @hynek's configs. https://twitter.com/hynek/status/696720593002041345
"""
This is an extension of the technique first detailed here:
http://sedimental.org/remap.html#add_common_keys
In short, it calls remap on each container, back to front, using the accumulating
previous values as the default for the current iteration.
"""
@AndrewJHart
AndrewJHart / restart_bluetooth.sh
Last active November 28, 2017 18:28 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting - this also works when the UI does not (preferences or menu bar)
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@AndrewJHart
AndrewJHart / react-controlled-inputs.md
Created February 19, 2018 20:53 — forked from markerikson/react-controlled-inputs.md
React "controlled" vs "uncontrolled" inputs explanation

[12:03 AM] acemarke: "controlled" and "uncontrolled" inputs
[12:04 AM] acemarke: if I have a plain, normal HTML page, and I put <input id="myTextbox" type="text" /> in my page(edited)
[12:04 AM] acemarke: and I start typing into that textbox
[12:04 AM] acemarke: it remembers what I've typed. The browser stores the current value for that input
[12:05 AM] acemarke: and then sometime later, I can get the actual element, say, const input = document.getElementById("myTextbox"), and I can ask it for its value: const currentText = input.value;
[12:05 AM] acemarke: good so far?
[12:08 AM] acemarke: I'll keep going, and let me know if you have questions
[12:08 AM] lozio: ok, actually I'm reading
[12:09 AM] lozio: good
[12:09 AM] acemarke: so, a normal HTML input field effectively stores its own value at all times, and you can get the element and ask for its value