Skip to content

Instantly share code, notes, and snippets.

@i-Hun
i-Hun / gist:5562503
Last active December 17, 2015 05:59
handlebars helpers style vs. meteor helpers style
//general Handlebars helper that we can use anywhere
Handlebars.registerHelper("formatDate", function(date) {
return new Handlebars.SafeString(
moment(date).format('LL')
);
});
//Плюрализация. Работает для всех шаблонов.
Handlebars.registerHelper('pluralize', function(n, thing) {
@i-Hun
i-Hun / gist:5643872
Created May 24, 2013 14:23
The process for doing this for GitHub is to first create a new repository, then follow the standard practice to get the package's code within that repository.
$ git init
$ git add -A
$ git commit -m "Created Errors Package"
$ git remote add origin https://github.com/tmeasday/meteor-errors.git
$ git push origin master
@i-Hun
i-Hun / gist:5730263
Created June 7, 2013 15:49
Meteor: how to access parent properties within nested templates?
Template.nestedTemplate.events({
'click a.class':function(event,template){
var parentID = template.data._id;
console.log(parentID);
}
});
//http://stackoverflow.com/questions/13091914/meteor-how-to-access-parent-properties-within-nested-templates
Не сразу понял, как в meteor выполнить сортировку по вложенным свойствам. Надо всего лишь взять их в кавычки:
Events.find({}, {sort: {"properties.title": 1}});
Это правило применимо к mongoDB в целом.
@i-Hun
i-Hun / gist:6018951
Created July 17, 2013 08:56
On ready patterns in Meteor
var eventsHandle = Meteor.subscribe('events');
var onReady = Deps.autorun(function () {
eventsHandle.ready();
});
onReady.onInvalidate(function() {
Events.find().observeChanges({
_suppress_initial: true,
added: function(id, event) {
@i-Hun
i-Hun / JS: анонимные самовызывающиеся функции
Created July 17, 2013 16:09
JS: анонимные самовызывающиеся функции
http://stackoverflow.com/questions/1122690/jquery-and-questions/1122740#1122740
Let's rewrite this code a little bit to understand what's going on.
function complicatedFunction($) {
// the document.ready call goes here.
}
Next, how would you call this function?
complicatedFunction(someObject);
So inside the complicatedFunction $ refers to someObject. Agree?
@i-Hun
i-Hun / JS: prototype and arguments
Last active December 19, 2015 21:39
JS: prototype and arguments
# Prototype
http://habrahabr.ru/post/117868/
arguments -- переменная, доступная внутри функции и содержащая аргументы и ссылку на саму функцию.
Несмотря на доступ по индексу и наличие свойства length, arguments не является массивом, т.е не принадлежит типу Array.
Поэтому для arguments нельзя напрямую вызвать методы этого класса:
arguments.pop() // ошибка !
Можно, однако, вызвать методы Array через apply/call:
var args = Array.prototype.slice.call(arguments, 0) //Мы вызываем метод slice прототипа Array от лица arguments.
from __future__ import division
from gensim import corpora, models, similarities, matutils
import numpy as np
import scipy.stats as stats
from scipy.sparse import linalg as splinalg
from scipy.sparse import *
import matplotlib.pyplot as plt
import h5py
from pymongo import MongoClient

Keybase proof

I hereby claim:

  • I am i-hun on github.
  • I am ihun (https://keybase.io/ihun) on keybase.
  • I have a public key ASBhm2M2hPPzVOZOB5EsVjOVTZquRH3ud-vu3GHQpELyKAo

To claim this, I am signing this object:

@i-Hun
i-Hun / getfit.py
Created May 18, 2018 10:01 — forked from cedricbonhomme/getfit.py
Get your Google Fit data
#! /usr/bin/env python
#-*- coding: utf-8 -*-
import json
import httplib2
from datetime import datetime
from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow