Ask

Archive

RSS

Theme
  1. Once again making meteor.js my bitch

    I guess 0.8.0 changed how they did their login flow with facebook

    I hacked together a different way to generate a profile and login with Facebook, since Meteor’s built in {{loginButtons}} do not work well when you are using the mobile web app capable meta tag, or ‘standalone’ mode on mobile

    You can read about it here

    All I had to do was add 

    var x = DDP._CurrentInvocation.get();
    var token = Accounts._generateStampedLoginToken();
    Accounts._insertLoginToken(userData.userId, token);
    Accounts._setLoginToken(userData.userId, x.connection, Accounts._hashLoginToken(token.token))x.setUserId(userData.userId)

    Dont ask me how I figured it out. I just looked at their accounts-base/accounts_server.js source code on github

    its 2am and my brain is fried.

  2. fuck it

    Im just gonna base64 encode my images and save them to my mongodb collection

    fuck turning them into a binary blob, and fuck uploading them to s3

    blobs have limited support, and uploading to s3 means having to download them every time the app loads

    running a few quick tests on my iPhone 4s iOS 7 loading 3 images from my localhost

    1: datauri base64 encoded loads the fastest

    2: binary blob

    3: s3 hosted image

    even on my macbook pro with 16gb ram, base64 wins out

    all of them have the same image loaded

    base64 encoded images have pretty broad support across browsers/devices

    so fuck it

    its quick and easy

  3. return List.find({$or : [{owner:userId}, {“admins.id” : {$in: [userId]}}]}, {sort: {‘index’: 1}})

    I fucking love Meteor.js

  4. So I spent my day figuring out how to save an image to amazon s3 using meteor.js

    Well, amazon’s nodejs aws-sdk

    but I fuckin did it.

    One step at a time.

        Meteor.methods({
      uploadImage: function(imgData, img_id) {
        var regex = /^data:.+\/(.+);base64,(.*)$/;
    
        var matches = imgData.match(regex);
        var data = matches[2];
        var buffer = new Buffer(data, 'base64');
    
    
        var uploadparams = {
              Key: img_id+'.jpg',
              ContentType: 'image/jpeg',
              Body: buffer,
              ACL: 'public-read'
            };
    
        s3.putObject(uploadparams, Meteor.bindEnvironment(function(error) {
          if(error) {
            console.log(error)
          }
          else {
            var url = 'https://s3-us-west-2.amazonaws.com/bucketname/'+img_id+'.jpg';
    
            Meteor.call('editImgSrc', img_id, url, function(error, data) {
              console.log(error, data);
            })
    
          }
        }))
      }
    });
    

    Where ‘img_id’ is the id of the ‘model’ or ‘data context’ 

  5. I'm making a browser extension for tumblr.

    shouuminazuki:

    dwightdoane:

    fuckyeahinitiald:

    dwightdoane:

    It will allow you to add tags to posts that you ‘like’, so that when you view your likes, a list of your tags will show up in the right side column and whenever you click on one, it will load those posts.

    You can make a ‘read later’, ‘watch later’, ‘favorite gifs’, and so on.

    Shameless self promotion

    This is pretty much done btw

    Aw yes! :^D

    Well for safari and chrome
    The only caveat is that it requires a Facebook authorization

    Long story short tumblr doesn’t provide any unique identifiers for users. They use blog names and emails which can be changed at anytime
    Where as your Facebook id never changes

    (via bsaapiers)

  6. I'm making a browser extension for tumblr.

    fuckyeahinitiald:

    dwightdoane:

    It will allow you to add tags to posts that you ‘like’, so that when you view your likes, a list of your tags will show up in the right side column and whenever you click on one, it will load those posts.

    You can make a ‘read later’, ‘watch later’, ‘favorite gifs’, and so on.

    Shameless self promotion

    This is pretty much done btw

    (via bsaapiers)

  7. Making Meteor.js my bitch once again.

    Today, I spent most of my day (probably a good 5 hours) reading Meteor.js’ source and trying to figure out how to get logging in with Facebook working via server side. 

    I finally figured it out.

    I needed to fix it in order for it to work with a mobile app i’m going to be making, which utitlizes 

    <meta name="apple-mobile-web-app-capable" content="yes">

    so that it runs in full screen without Safari’s url and menu bars getting in the way.

    Meteor uses a popup for facebook to authorize users. Which means opening up a new tab if you’re in regular safari mode, but if you’re in mobile web app capable mode, it breaks, and youre left at a blank white screen.

    So what I did was create a server side login, using Oauth.io to authorize and then go to a callback url and from there i’d capture all my facebook data, in order to create a user. Then from there its just logging in via meteor’s built in login function. 

    Since im using a callback url with Iron-Router, theres no need to open a popup. It redirects inside the app itself.

    Right now I was testing it inside Discover Meteor’s Microscope example app, since I just finished the book.

    Once I clean it up, and test it a bit more, I’ll do a more detailed write up with code examples.

  8. Picked up Discover Meteor today

    and I’m already half way through it in 2 hours

    I just wish I’d read it sooner.

    Definitely will come in handy when I rewrite Olli

  9. catkingcoletrickle:

    sooooo i may or may not have written some javascript that takes photos from yr webcam and draws them in the browser with like a million inline-styled divs.

    BECAUSE WTF ELSE IS CSS FOR?

    I did the same thing. Except I made it more pixelated 8bit looking so that it’s process faster.
    It’s fun messing with the css.
    Like adding a border the color of the pixel. And giving it a white background.

  10. I fixed a couple small bugs with my tumblr extension.

    As well as optimized it tremendously. Still could be a lot better, but Im rather satisfied with where its at now.

    Shouldn’t be too much longer till I make it public.