Skip to content

Instantly share code, notes, and snippets.

View Olegas's full-sized avatar

Oleg Elifantiev Olegas

  • Russia, Yaroslavl
View GitHub Profile
@Olegas
Olegas / post-update
Created December 10, 2012 07:21 — forked from dchest/post-update
Git post-update hook to checkout working copy and publish it with jekyll (put it into .git/hooks and chmod +x post-update)
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
@Olegas
Olegas / dns-domain.js
Last active December 17, 2015 07:39
NodeJS 0.8+ `dns.resolve4` bug. Callback is not invoked within domain.
/**
* Checked under 0.8.11, 0.8.23, 0.10.4
*
* macbook:work olegelifantev$ node -v
* v0.10.5
*
* Expected output:
* macbook:work olegelifantev$ node dns-domain.js
* Lookup. Domain present? yes
* Resolve4. Domain present? yes
@Olegas
Olegas / Reverse Polish Notation. Parser and calculator.
Created June 9, 2013 18:37
Experimenting on Reverse Polish notation.... Competing with @dftcdr and @dark_garret
function isOperator(c) {
return '/*+-^'.indexOf(c) != -1;
}
function peek(stack) {
return stack[stack.length - 1];
}
var doOper = {
'+': function(a, b) {
@Olegas
Olegas / gist:9143277
Last active May 26, 2016 04:52
iOS hover-click problem solution.
/**
* Solution for http://stackoverflow.com/questions/21786375/ios-7-hover-click-issue-no-click-triggered-in-some-cases
*/
$(document).ready(function(){
if (/* if this is not iOS */) {
return;
}
var $body = $('body');
@Olegas
Olegas / gist:9817229
Last active August 29, 2015 13:57
Monitor current focused element
var current = null;
$('<div />', {
html: '<style>@-webkit-keyframes changeopacity { from { opacity: 1 } to { opacity: 0.2 } }\
.indicate { -webkit-animation-duration: 0.25s; -webkit-animation-name: changeopacity; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; }\
.focus-mark-container { outline: 1px dotted red; }\
.focus-target-log { position: absolute; left: 0; top: 30px; background: blue; color: white; z-index: 20000 }\
.tabindex-indicator { z-index: 100000; opacity: 0.3; position: absolute; left: 0; top: 0; background: blue; color: white }\
.tabindex-indicator-current { background: red; }\
</style>'
@Olegas
Olegas / gitlab-teamcity-integration
Created November 4, 2014 20:34
Custom script to integrate GitLab with TeamCity 8+
// Configuration. GitLab API key, API url
var CIParams = {
gitlabKey: 'YOURSECREKAPIKEY',
gitlabApiUrl: 'https://gitlab/api/v3/',
tcApiUrl: '/guestAuth/app/rest/',
tcProtocol: 'https://'
},
cachedData = {
currentProject: {id: -1},
currentMergeRequest: {id: -1}
@Olegas
Olegas / autodoc.js
Last active August 29, 2015 14:09
How code style affects code review
{
/**
* Получить контрол по идентификатору.
* @param {String} id Идентификатор искомого контрола.
* @return {$ws.proto.Control} Найденный контрол.
* @deprecated Используйте $ws.proto.AreaAbstract.getChildControlByName
*/
get : function(id){
if (this._storage[id] === undefined)
throw new Error("ControlStorage : id = '" + id + "' not stored");
@Olegas
Olegas / bad.js
Created November 11, 2014 20:50
How code style affects code review
this.doWork({ amount: 6, unit: "hour" });
@Olegas
Olegas / 0-Description.md
Last active August 29, 2015 14:16
Read file stream line by line using generators
@Olegas
Olegas / demo.js
Created March 31, 2015 19:39
io.js worker disconnect bug
var cluster = require('cluster'),
net = require('net');
if (cluster.isMaster) {
console.log('Master started');
cluster.fork();
// Wait 10sec and disconnect worker
setTimeout(function(){