This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadCmdStatus = function() { | |
$.getJSON('/command/9857438925794/status', function(cmdReq) { | |
var now = new Date(); | |
beginTime = now.getTime(); | |
if (cmdReq.executed == '1' || cmdReq.executed == '0' || cmdReq.executed == '-1') { | |
} else { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Rake task with arguments and :environment" | |
task :task_name, [:arg1, :arg2] => :environment do |t, args| | |
args.with_defaults(:arg1 => "Foo", :arg2 => "Bar") | |
puts "Hello, #{args.arg1}. Bye, #{args.arg2}." | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('Program', { | |
extend: 'Ext.Panel', | |
id: 'program', | |
xtype: 'programview', | |
fullscreen: true, | |
config: { | |
layout: 'fit', | |
items: [ | |
{xtype:'titlebar', | |
docked: 'top', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.views.Signature=Ext.extend(Ext.Panel,{ | |
layout:{ | |
type:'vbox', | |
pack: 'start', | |
align: 'center' | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 ways to extract elements from within XML namespaces using Nokogiri | |
When trying to select elemenets in the default namespace, e.g. "xmlns= http://www.w3.org/2005/Atom", try the following two ways. Note the xmlns=" attribute on entry element: | |
Original xml: | |
Nokogiri::XML(@xml_string).xpath("//author/name").each do |node| | |
puts node | |
end | |
1. Define a namespace context for your XPath expression and point your XPath steps to match elements in that namespace. Define a namespace-to-prefix mapping and use this prefix (a) in the XPath expression. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require "socket" | |
module GwServer | |
# @server_socket = TCPSocket.open('127.0.0.1', 3000) | |
class GwTcpClient < EventMachine::Connection | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require "socket" | |
module GwServer | |
# @server_socket = TCPSocket.open('127.0.0.1', 3000) | |
# @queue = [] | |
class GwTcpClient < EventMachine::Connection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# terminal color setting | |
#terminal color setting | |
export TERM=xterm-color | |
export CLICOLOR=1 | |
export LSCOLORS=gxfxaxdxcxegedabagacad | |
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
# color the ls output | |
alias ls='ls -G' | |
# shortcut for detailed listing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Runs as follows: | |
# | |
# ~$ ruby tls-cert-generator.rb | |
require "openssl" | |
require "socket" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'base64' | |
require 'digest' | |
require 'openssl' | |
module AESCrypt | |
def AESCrypt.encrypt(password, iv, cleardata) | |
cipher = OpenSSL::Cipher.new('AES-256-CBC') | |
cipher.encrypt # set cipher to be encryption mode | |
cipher.key = password |