Skip to content

Instantly share code, notes, and snippets.

View deanrad's full-sized avatar
🎯
Staying On Target

Dean Radcliffe deanrad

🎯
Staying On Target
View GitHub Profile
# METEOR CORE:
Anywhere: Meteor.isClient
Anywhere: Meteor.isServer
Anywhere: Meteor.startup(func)
Anywhere: Meteor.absoluteUrl([path], [options])
Anywhere: Meteor.settings
Anywhere: Meteor.release
@CrabDude
CrabDude / callback_contract.md
Last active December 20, 2019 18:50
Node.js Callback Contract

Node.js Callback* Contract

(aka "errback" or "error first callback")

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
# This little gist shows how to easily internationalize your application using the meteor-just-i18n package.
# Package repository: https://github.com/subhog/meteor-just-i18n/
# 1. Adding the package.
$ meteor add anti:i18n
@fraserxu
fraserxu / auth.js
Last active February 6, 2018 09:51
Handling CORS in Meteor app
/*
* packages/reststop2/auth.js
* Add a method to handle OPTIONS request
*/
// return nothing
RESTstop.add('login', {'method': 'OPTIONS'}, function() {})
@deanrad
deanrad / load-it.js
Last active August 29, 2015 14:05
Load core Meteor Libraries for a Meteor-style REPL in the browser
var loadScript = function(url){
var d=document;
var s=d.createElement('script');
s.src=url;
(d.head || d.documentElement).appendChild(s)
};
/*needed for reactive-coffee, and meteor*/
loadScript('http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js');
/*Tracker.autorun (as Meteor.run), ReactiveDict (as ReactiveMap), ReactiveVar, and ReactiveObject */
loadScript('https://s3.amazonaws.com/www.chicagogrooves.com/js/mini-meteor.js');
// p = require('./extract_meteor_deps');
// Package = p.Package;
// getPackageDeps = p.getPackageDeps; depsByPackage = p.depsByPackage;
//
// > getPackageDeps('spacebars')
// ['htmljs', 'blaze', 'observe-sequence', 'templating']
// > depsByPackage
// {"spacebars": ['htmljs', 'blaze', 'observe-sequence', 'templating']}
var Package, api, depsByPackage, getPackageDeps, mockApiUse, _;
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@deanrad
deanrad / _README.md
Last active August 29, 2015 14:27
Meteor package.json for fun and profit

Why use pacakge.json with Meteor ?

  • Keep the preferred port with the project
  • Each project need not run on port 3000 (Keep your favicon.ico from getting confused!)
  • Start up with settings.json in a conventional way
  • Install utils with your project, like spacejam, ESLint, etc..
  • Have a uniform interface between package projects and meteor apps

How to use it ?

@gaearon
gaearon / connect.js
Last active June 24, 2024 09:43
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
const eventStub = value => ({
stopPropagation: () => {},
preventDefault: () => {},
persist: () => {},
target: {
value,
checked: value,
},
...value,
});