Skip to content

Instantly share code, notes, and snippets.

View KhodeN's full-sized avatar

Artem Berezin KhodeN

View GitHub Profile
@KhodeN
KhodeN / load_pageant.py
Created June 1, 2014 02:47
Start PAGEANT.EXE (ssh-agent for windows) with all *.ppk, collected recursively
import os
import sys
def get_files(only_ext):
for root, sub_folders, files in os.walk("."):
for file in files:
name, ext = os.path.splitext(file)
if ext == only_ext:
yield os.path.join(root, file)[2:]
@KhodeN
KhodeN / closeDubTabs.js
Created November 13, 2014 00:24
closeDubTabs
var getWindows = new Promise(function(resolve) {
chrome.windows.getAll(function(windows) {
resolve(windows);
});
});
var getTabs = function(window) {
var p = new Promise(function(resolve) {
chrome.tabs.getAllInWindow(window.id, function(tabs) {
@KhodeN
KhodeN / getBoundsWithBreaks.js
Created November 21, 2014 03:45
getBoundsWithBreaks
function getBoundsWithBreaks (text, subString) {
var breaks = [];
_.forEach(text, function (char, index) {
if (char === '\n') {
breaks.push(index);
}
});
var startIndex = text.replace(/\n/g, '').indexOf(subString);
if (startIndex === -1) {
// шлет запрос в сокет
_sendToMediator: function (query) {
var self = this;
return self._getMediator()
.then(function () {
if ( !self.mediator.connected ) {
// пытаемся еще раз подключиться к медиатору
self._getMediator(true);
return self.$q.reject(null);
}
var all_points = [];
var paths = route.getPaths();
var i = 0;
while (paths.get(i) !== null) {
var p = paths.get(i);
var segments = p.getSegments();
$(segments).each(function() {
var pc = this.getCoordinates();
$(pc).each(function() {
all_points.push(this);
@KhodeN
KhodeN / dockfox
Created November 7, 2015 12:03
run firefox in docker
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y firefox
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
@KhodeN
KhodeN / todo_import.py
Last active December 29, 2015 21:49
Import tasks from todolist *.tdl files to YouTrack. Support features and task.
import xml.etree.ElementTree as ET
from youtrack.connection import Connection
class Task(object):
def __init__(self, title, description):
self.title = title.encode('utf-8')
self.description = description.encode('utf-8')
self.feature = False
self.sub_tasks = []
{
"rules": {
"member-access": true,
"member-ordering": [
true,
"public-before-private",
"static-before-instance",
"variables-before-functions"
],
"no-any": false,
@KhodeN
KhodeN / dump.sh
Created January 28, 2016 09:37
dump psql by cron
#!/bin/bash
now=$(date +"%Y-%m-%d_%H:%M")
cd /projects/datamarket
pg_dump -U postgres dm | gzip > backups/dm_dump_$now.sql.gz
# use this row to backup every hour
# crontab -e
# * */1 * * * /projects/datamarket/dump.sh

Вертикальное выравнивание

Несколько модифицированная версия метода CSS-Tricks css-tricks.com/centering-in-the-unknown для вертикального центрирования элементов с динамическими размерами. Работает красиво и не требует дополнительных не-семантических элементов HTML.

@mixin ghostVerticalAlign(){
  &:before {
    content: '';
    display: inline-block;
 vertical-align: middle;