Skip to content

Instantly share code, notes, and snippets.

View jenya239's full-sized avatar

Evgeniy Arshanskiy jenya239

View GitHub Profile
@jenya239
jenya239 / html2ehtml.rb
Created October 12, 2014 23:24
html2ehtml
# encoding: utf-8
require 'nokogiri'
def walker node, indent = ''
if node.name == 'text'
indent + '"' + node.content.strip.gsub( '"', '\"' ) + '"'
else
attrs = '[' + node.attributes.map{ |el| '{' + ( el[1].name.include?( '-' ) ? "'#{ el[1].name }'" : el[1].name ) + ', "' + el[1].value + '"}' }.join( ', ' ) + ']'
children_for_print = node.children.reject{ |child| child.name == 'text' and child.content.strip.empty? }
@jenya239
jenya239 / change_watcher.rb
Last active July 9, 2017 17:31
change watcher
require 'diffy'
require 'awesome_print'
#require 'pry'
module J
class Change
@file
@diff
attr_reader :file, :diff
@jenya239
jenya239 / switch_in_current_desktop
Last active August 29, 2015 14:09
Switch to NAME in current desktop
NAME=$1;
DN=$(wmctrl -d | grep \* | sed 's/^\([[:digit:]]*\).*$/\1/g');
WID=$(wmctrl -l -p | grep ".* $DN .*" | grep $NAME | sed "s/^\([[:graph:]]*\)\ *$DN\ *[[:graph:]]*\ *.*$/\1/g");
wmctrl -i -a $WID
@jenya239
jenya239 / vk_photo_move_to_album_panel.js
Created April 18, 2016 21:39
vk photo move to album panel
var ma = document.createElement('div');
ma.setAttribute('style', 'font-size: 8px; width: 255px; right: 90px; opacity: 0.8; z-index: 700; position: absolute; background: white;');
document.querySelector('div.pv_fixed').appendChild(ma);
ajax.post('al_photos.php', {
act: 'a_move_to_album_box',
photo_id: cur.pvCurPhoto.id
}, {
onDone: function(title, html, js, data) {
var el = document.createElement('div');
el.innerHTML = html;
DIR=dirname; zip -rq ~/backup/$DIR`date +%Y%m%d-%H%M%S`.zip $DIR
data = STDIN.read
data = data.scan( /\d+/ ).map{ |is| is.to_i }
N = data.shift
K = data.shift
cables = data.clone
max = cables.max
max2 = 2 ** (Math::log(max+1) / Math::log(2)).ceil
l = step = max2 / 2
max_l = 0
while step > 0 do
@jenya239
jenya239 / delete_with_confirmation.iced
Created April 14, 2017 14:23
delete with confirmation
del = @_element.find 'button#delete'
del2 = @_element.find 'button#delete_confirmation'
del2.hide()
delay1 = null
delay2 = null
effect = [ 'slide', direction: 'left', 500 ]
hide_del2 = -> del2.hide.apply del2, effect
delay_args = [ hide_del2, 4000 ]
del.on 'click mouseenter', ( event ) =>
del2.css
@jenya239
jenya239 / .coffee
Created April 21, 2017 15:36
input check date yyyy-mm-dd
inpt = $ 'input.date'
inpt.on 'keypress', ( event ) =>
key = event.key
val = inpt.val()
unless /^[0-9\-]$/.test( key ) or event.ctrlKey or event.keyCode > 0
event.preventDefault()
if /^[0-9\-]$/.test( key )
if /^[0-9]{3}$/.test( val ) or /^[0-9]{2,4}\-[0-9]{1}$/.test( val )
inpt.val val + key + '-'
event.preventDefault()
{
"font_size": 9,
"tab_size": 2,
"detect_indentation": false,
"draw_white_space": "all"
}
require 'find'
paths = []
Find.find('.') do |path|
next unless path =~ /.*\.jar$/
next if path =~ /javadoc\.jar$/ or path =~ /sources\.jar$/
next if path.include? 'test'
paths << path
end
paths.each do | path |