Skip to content

Instantly share code, notes, and snippets.

@huezoaa
huezoaa / ruby_ftp_example.rb
Created Apr 17, 2020 — forked from 3dd13/ruby_ftp_example.rb
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
View ruby_ftp_example.rb
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@huezoaa
huezoaa / custom_headers.rb
Last active Aug 29, 2015 — forked from aliang/custom_headers.rb
setting custom headers with ruby net/http
View custom_headers.rb
# this was surprisingly difficult to find, the documentation and API is poor
require "net/http"
require "uri"
url = URI.parse("http://www.whatismyip.com/automation/n09230945.asp")
req = Net::HTTP::Get.new(url.path)
req.add_field("X-Forwarded-For", "0.0.0.0")
# For content type, you could also use content_type=(type, params={})
View map_hash_to_hash.rb
def transform_hash(original, options={}, &block)
original.inject({}){|result, (key,value)|
value = if (options[:deep] && Hash === value)
transform_hash(value, options, &block)
else
value
end
block.call(result,key,value)
result
}
@huezoaa
huezoaa / faker1.rb
Created Jun 26, 2015
faker_example
View faker1.rb
require 'rubygems'
require 'faker'
# puts "Please Enter your name: "
# person_name = gets.chomp
# puts "Please Enter your email address: "
# person_email = gets.chomp
View staffDiscount.js
function StaffMember(name,discountPercent){
this.name = name;
this.discountPercent = discountPercent;
}
var sally = new StaffMember("Sally",5);
var bob = new StaffMember("Bob",10);
// Create yourself again as 'me' with a staff discount of 20%
var me = new StaffMember("Angel", 20);
View hooverDam.js
var totalGen = 19;
var totalMW = 0;
var smallMW = 62;
var largeMW = 124;
var capacity = 0;
for (var genNum = 1; genNum <= totalGen; genNum++){
if (genNum <= 4){
capacity = smallMW;
}else{
@huezoaa
huezoaa / Input_Validation.js
Last active Aug 29, 2015
Input Validation - JQuery homework
View Input_Validation.js
$(function(){
$('input').change(function(x){
if (x.target.value !== "Wyncode"){
$(x.target).addClass('red');
};
});
})
@huezoaa
huezoaa / Input_Validation.css
Created Feb 5, 2015
Input Validation - JQuery homework
View Input_Validation.css
.red {
color: red;
border-color: red;
}
@huezoaa
huezoaa / Input_Validation.html
Created Feb 5, 2015
Input Validation - JQuery homework
View Input_Validation.html
<!doctype html>
<html>
<head>
<meta charset="UTF­8"></meta>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="Input_Validation.js"></script>
<link rel="stylesheet" type="text/css" href="Input_Validation.css" />
<title>InputValidation</title>
View hola_miami.html
<!DOCTYPE html>
<html>
<header>
<meta charset="UTF-8">
<title>Title goes here</title>
</header>
<body>
<h1>&iexcl;Hola Miami!</h1>
<h2>&Ccedil;a va?</h2>