dpkg -l linux-image*
uname -r
sudo apt-get remove linux-image-2.6.32-{21,37,38,39,40,41,42,43,44}-server
sudo apt-get autoremove
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
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
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' | |
| class Smtp < EM::P::SmtpServer | |
| require 'ostruct' | |
| @@received = 0 | |
| def initialize(*args) | |
| super | |
| @cache = "/tmp/cache" |
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
| include $(GOROOT)/src/Make.inc | |
| GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4 | |
| all: | |
| $(GC) jsontest.go | |
| $(LD) -o jsontest.out jsontest.$O | |
| format: | |
| $(GOFMT) -w jsontest.go |
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' | |
| class SmtpSink < EM::Protocols::SmtpServer | |
| def receive_data_chunk( data ) | |
| buffer.concat data | |
| end | |
| def receive_message | |
| puts |
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 'fog' | |
| require 'net/ssh' | |
| require 'net/scp' | |
| def upload_file(host, user, password, source, dest, print_progress = true) | |
| Net::SSH.start(host, user, :password => password) do |ssh| | |
| puts "Uploading file... (#{File.basename(source)})" | |
| ssh.scp.upload!(source, dest) do |ch, name, sent, total| | |
| if print_progress |
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/env ruby | |
| # == Simple Daemon | |
| # | |
| # A simple ruby daemon that you copy and change as needed. | |
| # | |
| # === How does it work? | |
| # | |
| # All this program does is fork the current process (creates a copy of | |
| # itself) then exits, the fork (child process) then goes on to run your | |
| # daemon code. In this example we are just running a while loop with a |
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 'resolv' | |
| class Domain | |
| def mxers(domain) | |
| mxs = Resolv::DNS.open do |dns| | |
| ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) | |
| ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] } | |
| end | |
| return mxs |
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
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
| # UPD from 2018: | |
| # This gist was written for pre-1.0 version of Elixir and won't work on post-1.0 versions. | |
| # You probably consider using something else! | |
| defmodule SecureRandom do | |
| @moduledoc """ | |
| Ruby-like SecureRandom module. | |
| ## Examples |
OlderNewer