Skip to content

Instantly share code, notes, and snippets.

users = new Meteor.Collection('Users');
Meteor.startup ->
Iconv = Meteor.require('iconv').Iconv
userIds = '53882537:128'
userInfo = HTTP.get(
'http://search.baihe.com/mystruts/userInfo.action',
{
params: {userIds: userIds}
headers: {"Content-Type": "application/json; charset=utf-8"}
}
@digilord
digilord / gist:8154137
Last active January 1, 2016 13:49
Tough Futures question
put.on('progress',function(progress){
// Update SOMETHING with the progress data
Meteor.bindEnvironment(function(){
S3files.update({file_name: file.name}, {$set: {percent_uploaded: progress.percent}});
},function(err){
console.log(err);
});
});
Template.s3progress.helpers({
progress: function () {
var file_name = Session.get('s3-file-name')
console.log(file_name);
if(file_name != null){
var file = S3files.findOne({file_name: file_name});
if(file){
console.log(file);
var percent = file.percent_uploaded
if(percent)
Knox = Npm.require("knox");
var Future = Npm.require('fibers/future');
var streamBuffers = Npm.require("stream-buffers");
var knox;
var S3;
Meteor.publish('s3files', function(){
return S3files.find({user: this.userId})
@digilord
digilord / gist:8209867
Created January 1, 2014 17:41
Meteor Nginx configuration with SSL
server {
listen 80;
server_name www.example.com;
# $scheme will get the http protocol
# and 301 is best practice for tablet, phone, desktop and seo
# return 301 $scheme://example.com$request_uri;
# We want to redirect people to the https site when they come to the http site.
return 301 https://example.com$request_uri;
}
@digilord
digilord / gist:8283707
Created January 6, 2014 14:42
Sample CoffeeScript controller for Iron Router
class @AuthorizedController extends RouteController
before: ->
console.log 'AuthorizedController :before action'
if not Meteor.user()?
@redirect 'salesLanding'
@Lexicon = new Meteor.Collection "lexicon"
if Meteor.isClient
Template.language_dropdown.rendered = ->
Lexicon.distinct "lang", (err, res) =>
$("#langs").autocomplete {source: res}
@Lexicon = new Meteor.Collection "lexicon"
@Langs = new Meteor.Collection(null)
if Meteor.isServer
for lang in Lexicon.distinct('lang')
Langs.insert lang
Meteor.publish 'lexicon', () ->
return Lexicon.find()
@Lexicon = new Meteor.Collection "lexicon"
if Meteor.isServer
Meteor.methods
Langs: -> Lexicon.distinct('lang')
if Meteor.isClient
Meteor.call 'Langs', (err, res) ->
console.log res
[digilord@Io meteor-weak-dependency-test[master]]$ meteor
[[[[[ ~/projects/meteor-weak-dependency-test ]]]]]
=> Errors prevented startup:
While building package `weak-test`:
error: no such package: 'iron-router'
=> Your application has errors. Waiting for file change.