Skip to content

Instantly share code, notes, and snippets.

View modond's full-sized avatar

Monique de Haas modond

View GitHub Profile
// subscribe to `CREATED`, `UPDATED` and `DELETED` mutations
this.newMessageObserver = this.props.client.subscribe({
query: gql`
subscription {
Message {
mutation # contains `CREATED`, `UPDATED` or `DELETED`
node {
text
sentBy {
name

CloudFormation snippet to create a VPC to be used for lambda functions. Qualities of the VPC:

  • 4 subnets: 2 public, 2 private (lambda functions should be attached to the private ones).
  • 2 Elastic IPs that can be used to identify traffic coming from lambda functions (e.g. for firewall holes).
  • Security group that can be used for lambda functions.

Notes:

  • uses regions us-east-1a, us-east-1b
  • uses ip block of 10.15.0.0/16 for VPC
@ptwobrussell
ptwobrussell / MTSW2E Example 6-3 Improvements
Last active December 26, 2016 23:08
A modification of MTSW2E Example 6-3 (http://bit.ly/1aWYgAv) with improvements toward getting the code to work seamlessly on mailboxes exported from Google Takeout.
"""
A modification of MTSW2E Example 6-3 (http://bit.ly/1aWYgAv) with the following modifications:
* Extra debugging information is written to sys.stderr to help isolate any problematic content
that may be encountered.
* A (hopeful) fix to a blasted UnicodeEncodeError in cleanContent() that may be triggered from
quopri.decodestring attempting to decode an already decoded Unicode value.
* The JSONification in jsonifyMessage now ignores any content that's not text. MIME-encoded content
such as images, PDFs, and other non-text data that is not useful for textual analysis without
significant additional work is now no longer carried forward into the JSON for import into MongoDB.
@hipertracker
hipertracker / meteor-pgsql.js
Last active January 4, 2016 14:29
PostgreSQL & MeteorJS
var pg = Meteor.require('pg'),
Future = Meteor.require('fibers/future'),
dbConf = process.env.METEOR_DB;
Database = {
async: function (sql, data) {
var deferred = Q.defer(); // https://github.com/frozeman/q-meteor
pg.connect(dbConf, function (err, client, done) {
if (err)
deferred.reject(err);
@auser
auser / app.js
Last active January 26, 2021 01:59
angular.module('myApp',
['ngRoute', 'myApp.services', 'myApp.directives']
)
.config(function(AWSServiceProvider) {
AWSServiceProvider.setArn('arn:aws:iam::<ACCOUNT_ID>:role/google-web-role');
})
.config(function(StripeServiceProvider) {
StripeServiceProvider.setPublishableKey('pk_test_YOURKEY');
})
.config(function($routeProvider) {
@dristic
dristic / 1.js
Last active January 20, 2022 18:46 — forked from ToeJamson/1.js
navigator.geolocation.getCurrentPosition(function (position) {
console.log(“I am located at: “ + position.coords.latitude + “, “ + position.coords.longitude);
});
navigator.geolocation.watchPosition(function (position) {
console.log(“I am now located at: “ + position.coords.latitude + “, “ + position.coords.longitude);
});
@kyledrake
kyledrake / bitcoind.js
Last active December 20, 2015 16:38
Probably the smallest feature-complete bitcoind RPC interface in existence.
var request = require('request');
function Bitcoind(url) {
this.url = url;
};
Bitcoind.prototype.rpc = function(method, params, callback) {
this.request({jsonrpc: '2.0', method: method, params: params}, callback);
};
@olizilla
olizilla / meteor-dump.sh
Last active May 29, 2016 02:18
Dump a mongo db from a live meteor app to a local dump dir.
#!/bin/bash
# __
# _____ ____ _/ |_ ____ ____ _______
# / \ _/ __ \ \ __\_/ __ \ / _ \ \_ __ \
# | Y Y \\ ___/ | | \ ___/ ( <_> ) | | \/
# |__|_| / \___ > |__| \___ > \____/ |__|
# \/ \/ \/
#
# .___
# __| _/ __ __ _____ ______
@philcockfield
philcockfield / document_model.coffee
Last active January 15, 2018 10:48
Meteor - Model (Logical Document Wrappers).
do ->
core = APP.ns 'core'
Model = core.Model
singletonManagers = {}
###
Base class for models that represent Mongo documents.
@possibilities
possibilities / meteor-async.md
Created August 23, 2012 22:53
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase: