Skip to content

Instantly share code, notes, and snippets.

View y-gagar1n's full-sized avatar

Yury Timofeev y-gagar1n

  • Yandex
  • Moscow, Russia
View GitHub Profile
@y-gagar1n
y-gagar1n / gist:a5dcba9bcc3f889912e2
Created August 16, 2014 21:33
debugging with node-inspector
sudo npm install -g node-inspector
sudo node-debug app.js --debug-brk
@y-gagar1n
y-gagar1n / gist:5656467
Created May 27, 2013 10:53
C# - Get XML from remote API
static IEnumerable<string> FetchStockQuotes(string[] symbols)
{
var quotes = new List<string>();
string url = string.Format("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20({0})&env=store://datatables.org/alltableswithkeys",
String.Join("%2C", symbols.Select(s => "%22" + s + "%22")));
var wc = new WebClient {Proxy = WebRequest.DefaultWebProxy};
var ms = new MemoryStream(wc.DownloadData(url));
var reader = new XmlTextReader(ms);
XDocument doc = XDocument.Load(reader);
@y-gagar1n
y-gagar1n / gist:5656772
Created May 27, 2013 12:17
C# - add unknown properties to dynamic object
dynamic expando = new ExpandoObject();
var p = expando as IDictionary<String, object>;
p["A"] = "New val 1";
Console.WriteLine(expando.A);
@y-gagar1n
y-gagar1n / gist:5663545
Created May 28, 2013 15:21
Python - Plugins installing
Для установки плагинов зайти в директорию плагина и запустить "python setup.py install"
Может ругаться на отсутствие setuptools, тогда нужно запустить файл http://python-distribute.org/distribute_setup.py
@y-gagar1n
y-gagar1n / gist:5734647
Created June 8, 2013 09:27
ASP.NET - Call method with jQuery AJAX
[WebMethod]
public static void SomeMethod(int paramA, string paramB)
{
...
}
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: window.location.href + "/SomeMethod",
@y-gagar1n
y-gagar1n / gist:5788834
Created June 15, 2013 17:25
Python - Print cyrillic symbols
import sys
import pprint
def pretty_print(object):
class decoder_stream:
def write(self, s):
if s.startswith("'") and s.endswith("'"):
s = "'%s'" % s[1:-1].decode('string_escape')
elif s.startswith("u'") and s.endswith("'"):
s = "u'%s'" % s[2:-1].decode('unicode_escape').encode('utf8')
@y-gagar1n
y-gagar1n / gist:5820503
Created June 20, 2013 05:30
jQuery - AJAX call
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: window.location.href + "/SomeMethod",
data: { paramA : valueA, paramB : valueB },
dataType: 'json',
success: function (response) {
...
}
});
@y-gagar1n
y-gagar1n / gist:6353759
Last active December 21, 2015 19:20
hg grep - Find revision history of specific line of code
hg grep --all "PATTERN" FILENAME
@y-gagar1n
y-gagar1n / gist:6742265
Created September 28, 2013 13:49
VisualStudio.gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
@y-gagar1n
y-gagar1n / AssertUtils.cs
Created December 4, 2017 08:53
AssertUtils
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace TestUtils