How to Use Python GroupBy on Data (List+Dict)

When working with data in Python, grouping by a certain key is a very common need. For example, when analyzing email logs, you might want to know how many emails were sent for each subject, or list the top five email providers for each subject. In a database, this is very simple. But what if you do not want to send the data to a database? Besides Pandas, the powerful data processing library that can help with this, Python itself also has GroupBy built in! ...

December 7, 2016 · 2 min

Tips for Uploading Large Files to Google Cloud Storage

I back up my data regularly. I copy my Google, Facebook, and Evernote data, photo albums, and more to Google Cloud Storage. Uploading through the browser always meant dealing with slow speeds, and if the connection dropped, I had to resend a 10 GB file from the beginning. So I read through the official documentation and found some handy tips for uploading large files to Google Cloud Storage, which I’m sharing here. This post covers: How to have GCP Storage verify a file's MD5 checksum How to enable resumable uploads, so a dropped connection doesn't mean starting over How to push your upload speed to the limit with parallel transfers ...

December 4, 2016 · 3 min

Enable Cross-Origin Resource Sharing (CORS) for Phaser.js

When you load resources and assets from a different domain in Phaser JS, the browser’s same-origin policy blocks them, and you get a pile of error messages, such as: XMLHttpRequest cannot load http://s.ntustcoding.club/scroll-game-workshop/map.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access. Actually, Phaser itself supports Cross-Origin Resource Sharing (CORS). You can solve this with one simple line, as long as the web hosting you use also supports CORS....

December 2, 2016 · 2 min

Enabling Cross-Origin Resource Sharing (CORS) on Google Cloud Storage

Recently I’ve been teaching a club class how to build small games with Phaser. Many of the assets need to be used by students on CodePen, so I needed web storage that supports CORS to host them. As I was brainstorming, I thought of Google Cloud Storage: it’s cheap, and you can bind it to your own domain! By default, Google Cloud Storage doesn’t support Cross-Origin Resource Sharing (CORS). But you can enable CORS on a specific bucket with gsutil (the Google Cloud Storage CLI tool)! ...

December 2, 2016 · 2 min

Facebook Graph API: How to Fix Missing Email Field for Some Users

I recently ran into a rather interesting little problem. A contest voting system we built had occasional users who couldn’t vote. The system was built with Laravel. Users could log in with Facebook to vote for a designated entry, one vote per day. We only collected the most basic Email and Name data, for the prize draw. Everything was fine during testing, but after launch, a few users complained that after voting they saw the error message “whoops looks like something went wrong,” while most users could vote normally. ...

December 2, 2016 · 3 min

Fixing the Unity 3D Error on Startup: Eorror loading page couldn't read a file ://file

Some friends installed Unity without any problems, but when they opened it they ran into the error message “Eorror loading page couldn’t read a file ://file”. My guess is that this error happens because the user name contains Chinese characters, which causes a problem when Unity tries to load the license key on its first run. The fix is actually easy: just import the license key into Unity manually. You can follow the tutorial below to do it. ...

January 26, 2014 · 1 min

SASS Basics: Variables, Mixins, Extend, and Nesting

In the previous article, “When CSS Meets Variables and Functions, It Becomes SASS: SASS Installation Tutorial”, I showed how to install SASS. In this article I’ll show you how to use SASS. It covers four of SASS’s main features: variables, mixins, extend, and nesting. ...

February 7, 2012 · 5 min

When CSS Meets Variables and Functions, It Becomes SASS: SASS Installation Tutorial

Anyone who writes both programs and CSS has probably wished that CSS could have variables and functions, the things programming languages have. Many CSS rules are repetitive, and if CSS had variables and functions, writing it would be a lot faster. Generally, that kind of dream seems impossible… But today I’ll introduce a new toy called SASS. With SASS, CSS can become something very different~ ...

February 7, 2012 · 4 min

MongoDB: A Document-Oriented NoSQL System, and an Installation Guide for Windows and Linux

A while ago, thanks to Ben’s guidance, I stepped into the NoSQL world, which I had always been interested in but never really tried. The first NoSQL system I came across (and still the only one I know) is MongoDB. I had read many articles about NoSQL and thought it was very different from regular SQL. But after actually using MongoDB, I found the two are quite similar. They differ a bit in principle, and NoSQL performs better. Of course, some things SQL can do, NoSQL can’t, so it comes down to the trade-offs and needs of each person. NoSQL itself isn’t what this post is about, though. This post introduces MongoDB and shows how to install it on Windows. ...

January 24, 2012 · 3 min

How to Create Databases and Collections in MongoDB?

Before, while I was playing with MongoDB, I spent a long time searching its official documentation for how to create databases and tables, but couldn’t find anything. In SQL, you normally have to create tables in advance, and there are commands for that, such as Create Table and Create Database. But I couldn’t find any similar commands in MongoDB. Later I looked it up online and learned that this is one of its features: Schema Free. ...

January 23, 2012 · 2 min