Skip to content

Instantly share code, notes, and snippets.

=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
@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.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;
@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 / injectCSS_demo2.html
Created May 7, 2014 12:57
Inject CSS with Javascript
<!DOCTYPE html>
<head>
<script src="injectCSS.js"></script>
</head>
<body>
<div class="test case1">test case 1</div>
<div class="test case2">test case 2</div>
<script>
(function(){
injectCSS(function(){/*
@patcullen
patcullen / injectCSS_demo1.js
Created May 7, 2014 12:56
Inject CSS with Javascript
require(['injectCSS'], function(injectCSS) {
injectCSS(function(){/*
.case1 {
border: 3px solid #0f0;
}
*/});
injectCSS('.case2 { border: 3px solid #00f; } ');
});
@patcullen
patcullen / AnchorTest.js
Created April 14, 2014 18:38
A snippet of JS to test how many links follow to a new target.
console.log('Location:', '' + window.location);
console.log('Number of links:', document.querySelectorAll('a').length);
console.log('Number of _blank links:', document.querySelectorAll('a[target="_blank"]').length);
console.log('% of _blank links:', ~~( document.querySelectorAll('a[target="_blank"]').length / document.querySelectorAll('a').length * 100 ) );