Skip to content

Instantly share code, notes, and snippets.

View LightVolk's full-sized avatar

Konstantin LightVolk

  • New-York
View GitHub Profile
@LightVolk
LightVolk / gist:4270022
Created December 12, 2012 17:54
How to make QMap in QMap : Qmap<QString,QQVariant>,where QVariant= QString,int
QVariantMap target,temp;
temp["KEY1"]=42;
temp["KEY2"]=24;
target["ID"]=temp;
@LightVolk
LightVolk / getHtml4pda.py
Created March 14, 2013 15:07
Get Html from 4pda. Test func.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import os
import sys
import lxml.html
def search_4pda(search):
headers = {'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'}
req = urllib2.Request("http://4pda.ru/forum/index.php?act=Search&source=all&forums=all&query="+search+"&result=topics", None, headers)
response = urllib2.urlopen(req)
//sample only, code completely untested.
template <typename Key, typename Value>
QMap<Key, Value> hashToMap(const QHash<Key, Value> hash) {
QMap<key, Value> result;
QHashIterator<Key, Value> it(hash);
while (it.hasNext()) {
it.next();
result.insert(it.key(), it.value());
}
return result;
@LightVolk
LightVolk / Windows Log
Created December 30, 2013 16:45
Create Windows log (or connect to it) and get log message from journal
interface ILog
{
IEnumerable<EventLogEntry> GetLogMessages();
}
class WinLog:ILog
{
private EventLog _EventLog;
public WinLog(String logName)
public string PostMethod(byte[] bytes)
{
string postUrl = "https://asr.yandex.net/asr_xml?" +
"uuid=01ae13cb744628b58fb536d496daa1e6&" +
"key="+your_api_key_here+"&" +
"topic=queries";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(postUrl);
request.Method = "POST";
request.Host = "asr.yandex.net";
@LightVolk
LightVolk / unity_architecture_error
Created May 1, 2015 18:44
Unity:Found plugins with same names and architectures
IF you see error like this:
Found plugins with same names and architectures, Assets/Plugins/x86_64/OculusPlugin.dll () and Assets/Plugins/x86/OculusPlugin.dll (). Assign different architectures or delete the duplicate.
UnityEditor.AndroidPluginImporterExtension:CheckFileCollisions(String)
Plugins colliding with each other.
You need to go to Projets->Plugins - see the dll (name without dll) and double click on it.
So, select the platform that this plugin shoud be. For example- Standalone-x86. Then apply.
public static Grammar MakeGrammar(String name,List<String> words)
{
Choices choises = new Choices();
GrammarBuilder gb = new GrammarBuilder();
gb.Culture = new CultureInfo("en-US");
if (choises == null)
throw new NullReferenceException("choises is null!");
if (words == null)
@LightVolk
LightVolk / js-from-translate-post.js
Created July 27, 2015 16:29
js-from-translate-post
<web:VideoStreaming runat="server" ID="video" ClientIDMode="Static" Width="300px" Height="300px" Interval="100" Source="True" ScalingMode="TargetSize" StreamingMode="Target" TargetClientID="received" OnStreamed="onStreamed" Style="border: solid 1px black" />

Введение

  • Главный вопрос: что и зачем вы измеряете?
  • Используйте библиотеки для бенчмаркинга: JMH, BenchmarkDotNet

Как правильно запускать бенчмарк

  • Release build
  • Без дебаггера
  • Выключите другие приложения
@LightVolk
LightVolk / door.ts
Last active January 26, 2020 18:26
IoBroker script: Main door script with Xiaomi door detector
var doorId="mihome.0.devices.some_id.state";
function SendToDevices(deviceId:string,message:string):void
{
sendTo(deviceId,message);
}
subscribe(doorId,function(obj)
{