Javascript – jQuery – Disable Button Based on Character Length

0
Filed under javascript, jquery
Tagged as , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: This script will disable “Go!” button if total characters more than 140 or have no character using jQuery framework.

<html>
  <head>
    <title>Twitter like text area</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
    <script type="text/javascript">
      $(function(){
          $("#my-submit-id").attr("disabled", "disabled");
          var chars = 0;
          $("#my-text-id").keyup(function(){
            chars = $(this).val().length;
            if ((chars < 1) || (chars > 140)){
              $("#my-submit-id").attr("disabled", "disabled");
            }
            else {
              $("#my-submit-id").removeAttr("disabled");
            }
              $("#my-label").text("Total characters: " + chars);
          });
        });
    </script>
  </head>
  <body>
    <form>
      <label id="my-label">Total characters: 0</label><br />
      <textarea id="my-text-id" name="my-text" rows="5" cols="20">
      </textarea><br />
      <input id="my-submit-id" type="submit" value="Go!" />
  </form>
  </body>
</html>



javascrip,logo,badge,pixel badge

Ruby – Simple Web Server

0
Filed under ruby
Tagged as , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple web server using Ruby’s standard library. Tested on Linux and Ruby 1.8.7.
Usage: ruby filename.rb

#!/usb/bin/ruby

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com

require 'webrick'

# importing WEBrick module
include WEBrick

# Creating HTTPServer instance on port 2000
server = HTTPServer.new(
:Port => 2000,
:DocumentRoot => "/home/slac3dork/ruby/www/"
)

# To shutdown server if get an interrupt signal (ctrl-c).
trap("INT"){ server.shutdown }

# To run the server
server.start




ruby,code,code,snippet

Ruby – Simple Port Scanner

0
Filed under ruby
Tagged as , , , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple Port Scanner Using Ruby. Tested on Linux. Thanks to someone who’s inspired me to create this script. I forget the name my inspirator, sorry.
Usage: ruby port_scanner.rb <target> <startPort> <endPort>

#!/usb/bin/ruby

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com
#
require 'socket'
require 'timeout'

class Scanner
  def Scanning(host, startPort, endPort)
    print "\nScanning ", host, "\n"
    for port in startPort..endPort
      begin
        s = TCPSocket.open(host, port)
        Timeout::timeout(1){s}
      rescue
        else
  	print "Port ",port,": Open\n"
  	s.close
      end
    end
  end
end

class Msg
  def hello
    puts "-------------------------------------"
    puts "Simple Port Scanner using Ruby"
    puts "Author: slac3dork"
    puts "I don't know who gives me inspiration to create this script"
    puts "-------------------------------------"
  end
end

if ARGV.length != 3
  puts "\nUsage: ruby port_scanner.rb <target> <startPort> <endPort>"
  exit(1)
end

target = ARGV[0]
startPort = ARGV[1].to_i
endPort = ARGV[2].to_i

host = Scanner.new
host.Scanning(target, startPort, endPort)




ruby,code,code,snippet