Skip to content

Instantly share code, notes, and snippets.

View ivankravchenko's full-sized avatar
🐌
moving fast

Ivan Kravchenko ivankravchenko

🐌
moving fast
View GitHub Profile
diff --git a/src/pkg/encoding/xml/read.go b/src/pkg/encoding/xml/read.go
index c216824..09f0d85 100644
--- a/src/pkg/encoding/xml/read.go
+++ b/src/pkg/encoding/xml/read.go
@@ -451,6 +451,51 @@ func (p *Decoder) unmarshalPath(tinfo *typeInfo, sv reflect.Value, parents []str
Loop:
for i := range tinfo.fields {
finfo := &tinfo.fields[i]
+ if finfo.flags&fAttr != 0 {
+ if len(finfo.parents) > len(parents) + 1 {
function View(template, model, parentNode) {
this.model = model
this.parentNode = null
this.bindings = {}
this.node = document.importNode(template.content, true)
this.childNodesSlice = Array.prototype.slice.apply(this.node.childNodes)
this.discoverNodes(this.node.childNodes)
this.setupObserve()
#!/bin/bash
URLS_FILE=$1
while read URL; do
TIME=`curl --silent -w '%{time_total}' -o /dev/null $URL`
echo "${TIME}s $URL"
done <$URLS_FILE
<!-- http://htmlbook.ru -->
<!-- Sublime Text 3 -->
<html>
<head>
<meta charset="utf8">
<title>Moneycalc</title>
<style>
* {
@ivankravchenko
ivankravchenko / Procfile.dev-verstat
Created January 19, 2015 16:02
Procfile.dev-verstat and verstat2wp.sh
web: vendor/bin/heroku-php-nginx -C app_nginx.conf -F app_php-fpm.conf app
verstat: cd verstat ; npm install ; verstat --exec-after-generate 'cd .. ; ./verstat2wp.sh' serve
[
{
id: "burger-grill-bbq",
category: "Бургеры",
title: "Бургер с грилловаными овощами с соусом BBQ",
thumb: "http://placehold.it/350x260",
price: 28,
weight: 128,
nutrition: ['бургер', 'гриллованые овощи', 'соус BBQ', 'дизайн', 'верстка'],
addables: ['cheeses', 'cutlet']
@ivankravchenko
ivankravchenko / gist:1a57402a960e63d005d5
Created August 13, 2014 21:30
flynn error log samples
{"s":1,"t":1407963842576,"m":"[etcd] Aug 13 21:04:02.575 INFO | Discovery via https://discovery.etcd.io using prefix /[cut].\n"}
{"s":1,"t":1407963842975,"m":"[etcd] Aug 13 21:04:02.975 WARNING | Discovery encountered an error: Discovery found an initialized cluster but no reachable peers are registered.\n"}
{"s":1,"t":1407963842975,"m":"[etcd] Aug 13 21:04:02.975 WARNING | \u003cno value\u003e failed to connect discovery service[https://discovery.etcd.io/[cut]] Discovery found an initialized cluster but no reachable peers are registered.\n[etcd] Aug 13 21:04:02.975 CRITICAL | \u003cno value\u003e, the new instance, must register itself to discovery service as required\n"}
<?php
error_reporting(E_NONE);
$cnt = 100;
$t1 = microtime(true);
$a = 4;
for ($i=1; $i<=$cnt; $i++) { if ($a) { 1+1; } }
$t2 = microtime(true);
unset($a);
for ($i=1; $i<=$cnt; $i++) { if ($a) { 1+1; } }
#!/bin/bash
URLS_FILE=$1
while read URL; do
TIME=`curl --silent -w '%{time_total}' -o /dev/null $URL`
echo "${TIME}s $URL"
done <$URLS_FILE
@ivankravchenko
ivankravchenko / wordpress-tr.php
Created July 21, 2014 09:31
wordpress translate helper
<?php
/*
* tr – translation helper
* examples:
* tr("Hello") -> "Привіт" // simply translates given string
* tr("%s products", $category) -> "Продукти категорії " // translates format and uses sprintf for substitutions
* tr(array("%d comment", "%d comments"), $commentCount) -> "1 comment" // pluralized format version
*/
function tr() {