Skip to content

Instantly share code, notes, and snippets.

@patcullen
patcullen / excel-js.asp
Created May 27, 2014 06:36
An example of connecting to an Excel file in ASP (using JScript)
<%@ Language=JScript %>
<!--#include file="excel.asp" --><%/* https://gist.githubusercontent.com/patcullen/096a79ca8000b367537e/raw/7a806439bdf388335f2403ba89d8f51f039fb6a8/excel.asp */%>
<!--#include file="json.asp" --><%/* https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js */%>
<%
excelFile = "c:/temp/unlocodes.xlsx"
sql = "SELECT [ISO 3166-1], [Country Name] FROM [Sheet1$]"
excel.open(excelFile).query(sql, {}, function(codes) {
Response.write(
@patcullen
patcullen / excel-vb.asp
Created May 27, 2014 05:40
A sample ASP (VB) script for reading from an Excel file
<%
ExcelFile = "c:\temp\unlocodes.xlsx"
SQL = "SELECT [ISO 3166-1], [Country Name] FROM [Sheet1$]"
Set ExcelConnection = Server.createobject("ADODB.Connection")
ExcelConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ExcelFile & ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"";"
SET RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, ExcelConnection
Response.Write "<table border=""1""><thead><tr>"
@patcullen
patcullen / excel.asp
Created May 27, 2014 06:34
A helper for working with Excel files in classic ASP using JScript
<%
var excel = (function () {
var connection = null;
function open(file) {
connection = Server.createObject('ADODB.Connection');
connection.CommandTimeout = 60;
connection.CursorLocation = 3;
<html><head>
<script src="sea.js"></script>
<script src="jquery.js"></script>
<script>
$(function(){
function fakeXHR(url, callback) {
setTimeout(function(){callback('This is some pseudo XHR content. Random number: '+Math.random());}, Math.random()*1000+500);
}
seajs.use('loading', function(loading) {
$('#btnRequest').click(function() {
<html><head>
<script src="mootools.js"></script>
<script src="loading-mt-office-x-min.js"></script>
<script>
window.addEvent('domready', function(){
$('btnRequest').addEvent('click', function() {
var anim = loading.start($('btnRequest'));
fakeXHR('goesNowhere.php', function(result) {
$('txtResult').set('text', result);
anim.stop();
@patcullen
patcullen / JSONValidate.js
Created May 28, 2013 20:33
A function to validate JSON objects against a schema.
// used in schema valiadtion for json objects
String.prototype.fromCamelToLabel = function() {
return this[0].toUpperCase() + this.substring(1).replace(/[A-Z]/g, function(h){
return " "+h;
});
};
var jv = {};
// Validate an object against a predefined schema.
=begin
A simple algorithm, not the most efficient*, can be explained as:
Iterate through every element in the array; call the current one "outer":
For every element after "outer", Step through and compare to "outer"
If the difference is larger than previously compared, store the result.
At the end, show the largest difference.
I read up on a few more advanced algorithms that should be more efficient,
def firstchar_map(input)
return input.split.map(&:chr)*''
end
puts firstchar("hello world")
puts firstchar("what you see is what you get")
# this is my very first ruby function, so here's where i learned from...
# - commenting: http://www.tutorialspoint.com/ruby/ruby_comments.htm
{
"result": [
"ftp> Local directory now C:\\some\\virtual\\folder.",
"ftp> lcd c:\\some\\folder\\and\\directory",
"Connected to some.site.com.",
"open some.site.com",
"220 Microsoft FTP Service",
"User (some.site.com:(none)): ",
"331 Password required for some_user.",
"",
<%@ Language=JScript %>
<!--#include file="json.asp" --><%/* https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js */%>
<%
var ftp = (function() {
/*
* Copy a file(s) to a directory on a remote FTP server.
*
* Adapted from the very usefull post @ http://benmeg.com/code/asp/ftp.asp.html