Skip to content

Instantly share code, notes, and snippets.

View hamxiaoz's full-sized avatar

Andrew Zheng hamxiaoz

View GitHub Profile
// loop over all rows in spreadsheet (note: watch out for header row!)
for (var i = 9000; i <= numRows - 1; i++) {
row = values[i];
address = row[0];
lat = row[1];
// skip if we've already done this row (for repeat runs etc)
if (typeof lat === "number"){ continue; }

Tutorial: Meteor in Windows using Vagrant

These days some people were discussing at meteor-talk group about running Meteor at Windows and I’ve recommended them using Vagrant. It’s a very developer-friendly piece of software that creates a virtual machine (VM) which let you run any operating system wanted and connect to it without big efforts of configuration (just make the initial installation and you have it working).

Many packages (I've tested) for running Meteor+Vagrant fails because Meteor writes its mongodb file and also other files inside local build folder into a shared folder between the Windows host and the Linux guest, and it simply does not work. So I've put my brain to work and found a solution: do symlinks inside the VM (but do not use ln. Use mount so git can follow it). It’s covered on steps 8 to 15.

If you have no idea what I’m talking about, I’ve made a tutorial to install Ubuntu Precise x86 through Windows command-line with Meteor very simple to follow

// Example:
// http://github.com/chris/project123/blob/master/new_mailer/install-file.rb
// 104-116-116-112-58-47-47-103-105-116-104-117-98-46-99-111-109-47-99-104-114-105-115-47-112-114-111-106-101-99-116-49-50-51-47-98-108-111-98-47-109-97-115-116-101-114-47-110-101-119-95-109-97-105-108-101-114-47-105-110-115-116-97-108-108-45-102-105-108-101-46-114-98
function string2charCodeString (s){
if(typeof(s) != 'string') return false;
a = [];
f = s.length;
for (i = 0; i<f; i++) {
a[i] = s.charCodeAt(i);
+autoForm collection="ProductScopes" id="insertProductScopeForm" type='insert'
+afQuickField name='name'
.form-group(class="{{#if afFieldIsInvalid name='color'}}has-error{{/if}}")
+afFieldLabel name='color'
+afFieldInput name='color'
if afFieldIsInvalid name='color'
span.help-block {{afFieldMessage name='color'}}
button.btn.btn-primary(type="submit") Insert
@hamxiaoz
hamxiaoz / UI events
Last active August 29, 2015 14:02
Helpers or Utilities I used in Meteor.js project
// https://github.com/hharnisc/meteor-accounts-admin-ui-bootstrap-3/blob/bc613e55d4e8c9b419b798e92d274dc697d68b15/client/accounts_admin.js#L35
// search no more than 2 times per second
var setUserFilter = _.throttle(function(template) {
var search = template.find(".search-input-filter").value;
Session.set("userFilter", search);
}, 500);
Template.accountsAdmin.events({
'keyup .search-input-filter': function(event, template) {
@hamxiaoz
hamxiaoz / gist:d3029c9fba8d0faaaa0d
Created December 3, 2014 19:40
Datatables init
$('#channels-table').dataTable
scrollX: true
scrollY: '600px'
scrollCollapse: true
paging: false
destroy: true
dom: 'lrtip' # remove filter but keep 'searching' option in order to make column filter work
# table row select effect
$('#channels-table tbody tr').on 'click', (e)->
@hamxiaoz
hamxiaoz / CoffeeScript
Last active August 29, 2015 14:23
In place edit in Meteor using template instance and afterFlush
Template.imageDescription.onCreated ->
template = this
# template level instance
template.editing = new ReactiveVar(false)
template.saving = new ReactiveVar(false)
# Automatically focus the input
Tracker.autorun ->
editing = template.editing.get()
if editing
@hamxiaoz
hamxiaoz / save.js
Created July 26, 2015 16:41
A way to generate and download CSV files client-side
// https://github.com/mholt/PapaParse/issues/175
var blob = new Blob([csvString]);
if (window.navigator.msSaveOrOpenBlob) // IE hack; see http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx
window.navigator.msSaveBlob(blob, "filename.csv");
else
{
var a = window.document.createElement("a");
a.href = window.URL.createObjectURL(blob, {type: "text/plain"});
a.download = "filename.csv";
document.body.appendChild(a);
@hamxiaoz
hamxiaoz / isxdl.cs
Last active February 17, 2016 23:34
How to use [isxdl.dll](http://woohaeng.com.ne.kr/docs/isxdl.htm) to download files in C#?
[DllImport("isxdl.dll")]
static extern Int32 isxdl_Download(IntPtr hWndParent, String pszURL, String pszFileName);
[DllImport("isxdl.dll")]
static extern Int32 isxdl_SetOption(String option, String value);
private void button_download_Click(object sender, EventArgs e)
{
var fileUrl = "REPLACE_ME";
@hamxiaoz
hamxiaoz / crontab
Last active March 8, 2016 17:54
Use git to backup MongoDB for Meteor
# run every day at 12am
00 00 * * * /home/x/run_backup.sh