Skip to content

Instantly share code, notes, and snippets.

View glebtv's full-sized avatar

Gleb glebtv

View GitHub Profile
$('.timep input').off('blur').blur(function() {
var $t = $(this), v = $t.val();
v = v.replace(':', '');
v = v.replace('-', '');
if (v > 2400) {
v = '0000';
}
if (v.match(/\d{4}/)) {
$t.val(v.substr(0, 2) + ':' + v.substr(2, 2));
} else if (v.match(/\d{2}/)) {
@glebtv
glebtv / rvm-log.sh
Last active December 29, 2015 09:58
apt-get install sudo curl vim wget
apt-get install -y build-essential libffi-dev libgdbm-dev libncurses5-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev
gleb@debian:~$ \curl -L https://get.rvm.io | bash -s stable --without-gems="rubygems-bundler"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 206 0 --:--:-- --:--:-- --:--:-- 296
100 19527 100 19527 0 0 14395 0 0:00:01 0:00:01 --:--:-- 14395
Installing RVM without gems: rubygems-bundler.
Downloading RVM branch stable
Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz to rvm-stable.tgz.
require 'msgpack'
require 'thread'
class ProcessPool
def initialize(num_process, args={})
queue_size, worker_class = parse_args([
:queue_size, nil,
:worker_class, Worker,
], args)
@glebtv
glebtv / work.rb
Created December 4, 2013 15:47 — forked from rklemme/work.rb
require 'set'
LOCK = Mutex.new
num = Integer(ARGV.shift || 4)
processes = Set.new
Signal.trap "INT" do |s|
$stderr.puts "Shutdown"
def thread_state(thr)
vars = Hash[thr.thread_variables.map do |k|
[k, thr.thread_variable_get(k)]
end]
{
status: thr.status,
stop: thr.stop?,
alive: thr.alive?,
aoe: thr.abort_on_exception,
backtrace: thr.backtrace,
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
class NavRenderer < SimpleNavigation::Renderer::List
def icon_for(item)
(if item.send(:options)[:icon]
"<img class='icon' src='#{item.send(:options)[:icon]}' alt=''/> ".html_safe
else
""
end) + item.name
end
def tag_for(item)
if suppress_link?(item)
RocketCMS.patch 'Page' do
model do
has_attached_file :icon
validates_attachment_content_type :icon, content_type: /\Aimage\/.*\Z/
end
edit do
field :icon
end
end
> ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.31 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.776 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.638 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.674 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.595 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=146 ms
64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=2.25 ms
64 bytes from 192.168.1.1: icmp_seq=26 ttl=64 time=156 ms
[ 34.173417] usb 1-2: new high-speed USB device number 6 using xhci_hcd
[ 53.745299] mt7610u: loading out-of-tree module taints kernel.
[ 53.747531]
=== pAd = ffffc90001506000, size = 895272 ===
[ 53.747592] <-- RTMPAllocTxRxRingMemory, Status=0
[ 53.747620] <-- RTMPAllocAdapterBlock, Status=0
[ 53.747702] ==>MT76x0_WLAN_ChipOnOff(): OnOff:1, Reset= 0, pAd->WlanFunCtrl:0x0, Reg-WlanFunCtrl=0xff000002
[ 53.748159] pChipOps->eeread = RTUSBReadEEPROM16