Skip to content

Instantly share code, notes, and snippets.

View sergeyt's full-sized avatar
:electron:
There is a time for everything, a time to search and, a time to give up...

Sergey Todyshev sergeyt

:electron:
There is a time for everything, a time to search and, a time to give up...
View GitHub Profile
@sergeyt
sergeyt / get-nuget.cmd
Created October 14, 2013 15:01
cmd script to download nuget.exe
powershell -Command "(new-object System.Net.WebClient).DownloadFile('http://az320820.vo.msecnd.net/downloads/nuget.exe', '.nuget\NuGet.exe')"
@sergeyt
sergeyt / cors.global.asax
Created October 16, 2013 15:19
global.asax to enable CORS on IIS server
<%@ Application Language="C#" %>
<script runat="server">
void Application_BeginRequest(object sender, EventArgs e)
{
var context = HttpContext.Current;
var response = context.Response;
// enable CORS
response.AddHeader("Access-Control-Allow-Origin", "*");
@sergeyt
sergeyt / flatten.cs
Created November 6, 2013 02:20
flatten enumerable extension
internal static class Extensions
{
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> childSelector)
{
foreach (var item in source)
{
yield return item;
foreach (var d in childSelector(item).Flatten(childSelector))
{
@sergeyt
sergeyt / meteor-typeahead-nba.html
Last active December 31, 2015 22:29
gist for meteor-typeahead demo
<input class="form-control typeahead" name="team" type="text"
placeholder="NBA teams"
autocomplete="off" spellcheck="off"
data-source="nba"/>
@sergeyt
sergeyt / meteor-typeahead-nba.js
Last active December 31, 2015 22:39
gist for meteor-typeahead demo
Nba = new Meteor.Collection("nba");
if (Meteor.isServer){
Nba.insert({name:'Boston Celtics'});
// fill Nba collection
}
Template.demo.nba = function(){
return Nba.find().fetch().map(function(it){ return it.name; });
};
@sergeyt
sergeyt / meteor-typeahead-data-sets.html
Last active December 31, 2015 22:39
gist for meteor-typeahead demo
<input class="form-control typeahead" name="team" type="text"
placeholder="NBA and NHL teams"
autocomplete="off" spellcheck="off"
data-sets="teams"/>
@sergeyt
sergeyt / meteor-typeahead-data-sets.js
Last active December 31, 2015 22:39
gist for meteor-typeahead demo
Template.demo.teams = function(){
return [
{
name: 'nba-teams',
local: function() { return Nba.find().fetch().map(function(it){ return it.name; }); },
header: '<h3 class="league-name">NBA Teams</h3>'
},
{
name: 'nhl-teams',
local: function() { return Nhl.find().fetch().map(function(it){ return it.name; }); },
@sergeyt
sergeyt / meteor-typeahead-template.html
Last active December 31, 2015 22:39
gist for meteor-typeahead demo
<input class="form-control typeahead" name="repo" type="text"
placeholder="open source projects by Twitter"
autocomplete="off" spellcheck="off"
data-source="repos" data-template="repo"/>
<template name="repo">
<p class="repo-language">{{language}}</p>
<p class="repo-name">{{name}}</p>
<p class="repo-description">{{description}}</p>
</template>
@sergeyt
sergeyt / meteor-typeahead-repos.js
Last active December 31, 2015 22:39
gist for meteor-typeahead demo
Repos = new Meteor.Collection("repos");
if (Meteor.isServer){
Meteor.startup(function(){
Repos.remove({});
// fill repos from private repos.json asset
JSON.parse(Assets.getText('repos.json')).forEach(function(it){
Repos.insert(it);
});
});