Skip to content

Instantly share code, notes, and snippets.

@huezoaa
huezoaa / ruby_ftp_example.rb
Created April 17, 2020 03:51 — 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
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 August 29, 2015 14:25 — forked from aliang/custom_headers.rb
setting custom headers with ruby net/http
# 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={})
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 June 26, 2015 04:06
faker_example
require 'rubygems'
require 'faker'
# puts "Please Enter your name: "
# person_name = gets.chomp
# puts "Please Enter your email address: "
# person_email = gets.chomp
@huezoaa
huezoaa / staffDiscount.js
Created March 26, 2015 03:48
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);
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 August 29, 2015 14:14
Input Validation - JQuery homework
$(function(){
$('input').change(function(x){
if (x.target.value !== "Wyncode"){
$(x.target).addClass('red');
};
});
})
@huezoaa
huezoaa / Input_Validation.css
Created February 5, 2015 20:51
Input Validation - JQuery homework
.red {
color: red;
border-color: red;
}
@huezoaa
huezoaa / Input_Validation.html
Created February 5, 2015 20:50
Input Validation - JQuery homework
<!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>
@huezoaa
huezoaa / hola_miami.html
Created February 1, 2015 20:08
Hola Miami
<!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>