Skip to content

Instantly share code, notes, and snippets.

View matb33's full-sized avatar

Mathieu Bouchard matb33

View GitHub Profile
@matb33
matb33 / install-meteor-cordova.sh
Last active August 29, 2015 14:07
Temporary measure to install a different version of Cordova in Meteor
#!/bin/bash
# Make sure to update METEOR_VERSIONS below to point to your app's versions file
TARGET_VERSION=$1
BASEPATH="$(dirname "$0")"
BASEPATH="$(cd "$BASEPATH" && pwd)"
METEOR_VERSIONS=$BASEPATH/../app/.meteor/versions
if [ "$TARGET_VERSION" == "" ]; then
@matb33
matb33 / getprimaryip.sh
Created December 13, 2014 14:38
Utility script to get the primary local IP address on your system. Works in Linux and OSX.
#!/bin/bash
if [ "$(which ipconfig)" != "" ]; then
for i in $(ifconfig -ul); do
if [[ $i != lo* ]]; then
ipaddr=$(ipconfig getifaddr $i)
if [ "$ipaddr" != "" ]; then
echo $ipaddr
exit 0
fi
@matb33
matb33 / facebook.html
Created December 22, 2014 17:21
FacebookCollections help for Eduardo
<head>
<title>facebook</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> loginButtons}}
{{> posts}}
</body>
@matb33
matb33 / gist:1229317
Created September 20, 2011 14:57
Inline variable parsing function with multibyte support
<?php
// parseInlineVariables takes a multibyte string "stringToParse" and parses for $variable style
// variables to swap with the value found in the "variables" associative array. It also supports
// better matching with curly braces surrounding the variable, such as {$variable}. Spaces
// within the curly braces are OK: { $variable } works too.
// Adapt this function to your particular framework (put it in a class, keep it global, etc)
function parseInlineVariables( $stringToParse, Array $variables )
{
@matb33
matb33 / publishCursor.js
Created October 4, 2012 15:08
Alternate _publishCursor for Meteor
// Meteor extension to allow modifications to documents when publishing.
// Also allows specifying an alternate name under which to publish the
// collection, using "sub_name".
_.extend(Meteor._LivedataSubscription.prototype, {
_publishCursor: function (cursor, name) {
var self = this;
var collection = name || cursor.sub_name || cursor.collection_name;
var map_callback = cursor.map_callback || function (obj) { return obj; };
@matb33
matb33 / stuff.html
Created February 14, 2013 15:25
Example of X new things in Meteor, leveraging local collection
<template name="stuff">
<button name="show">Show {{newThingsCount}} new things</button>
<ul>
{{#each things}}
<li>{{title}}</li>
{{/each}}
</ul>
</template>
@matb33
matb33 / collection-hooks.js
Last active December 15, 2015 12:09
Collection hooks for Meteor: allows you to run callbacks before and after any insert/update/remove to collections. Works across both server and client. Drop this file into a shared folder, for example: `/lib/external/collection-hooks.js`
MOVED: https://github.com/matb33/meteor-collection-hooks
@matb33
matb33 / gist:5322002
Last active December 15, 2015 20:58
Automated server installation for Meteor 0.6.0+ on a fresh AWS EC2 Ubuntu Server 12.10 installation. Although MongoDB is installed, I only tested against having my database remotely on MongoHQ. Let me know if you have issues with a local DB. Moved: https://github.com/matb33/meteor-ec2-install
MOVED: https://github.com/matb33/meteor-ec2-install
@matb33
matb33 / example.js
Last active December 15, 2015 23:29
SyncObject smart package for Meteor. Drop this in your Meteor app /packages/syncobject/
ServerTime = (function () {
var sync = new Meteor.SyncObject("serverTime");
var intervalId;
function updateTime() {
sync.set({ms: Date.now()});
}
function updateInterval(intervalMs) {
@matb33
matb33 / aws-sdk.js
Created April 12, 2013 19:09
AWS SDK Smart Package -- Exposes the SDK as AWS.SDK and provides a helper function to sign URLs
AWS = (function () {
var SDK = Npm.require("aws-sdk");
var crypto = Npm.require("crypto");
var url = Npm.require("url");
function getAuthenticatedURL(fullUrl, accessKeyID, secretAccessKey, expires) {
/*
Signature = URL-Encode( Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ) );