Skip to content

Instantly share code, notes, and snippets.

View dcabines's full-sized avatar

David Cabiness dcabines

View GitHub Profile
@dcabines
dcabines / gist:f7e584d372d35f5c384dfe210925baa3
Created July 23, 2020 15:50
The Harper’s ‘Letter,’ cancel culture and the summer that drove a lot of smart people mad
By
Sarah Ellison and
Elahe Izadi
July 23, 2020 at 9:20 a.m. EDT
This is what was on Thomas Chatterton Wiliams’s mind when he decided to write a short letter on the risks to liberalism and open discourse and get some like-minded thinkers to sign on.
He was thinking of the Poetry Foundation, whose leaders resigned after their four-sentence statement in support of Black Lives Matter was deemed too tepid by 1,800-plus petition-signers. And the National Book Critics Circle, whose board imploded over its own attempt at such a statement.
He was thinking of David Shor, a political scientist who was fired after tweeting about a study suggesting that violent street protests helped tip the 1968 election to the GOP; and Colin Kaepernick, a quarterback who was shunned from the NFL after his anti-racism activism ran afoul of conservative fans.
@dcabines
dcabines / String.prototype.toSmallCaps.js
Created February 17, 2016 18:44
This is the same as the last one, just done a little differently.
String.prototype.toSmallCaps = (function () {
var letters = "abcdefghijklmnopqrstuvwxyz";
var caps = "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ";
function translate(character) {
var index = letters.indexOf(character);
return index !== -1 ? caps.charAt(index) : character;
}
function mapReduce(value, transform) {
@dcabines
dcabines / toSmallCaps.js
Last active June 17, 2016 01:30
Cᴏɴᴠᴇʀᴛ ʟᴏᴡᴇʀ ᴄᴀsᴇ ʟᴇᴛᴛᴇʀs ɪɴ ᴀ sᴛʀɪɴɢ ᴛᴏ sᴍᴀʟʟ ᴄᴀᴘs. Fᴀᴄᴇʙᴏᴏᴋ sᴜᴘᴘᴏʀᴛs sᴍᴀʟʟ ᴄᴀᴘs.
window.toSmallCaps = (function () {
var letters = "abcdefghijklmnopqrstuvwxyz";
var caps = "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ";
return function replace(value) {
var newValue = '';
for (i = 0; i < value.length; i++) {
var letter = value[i];
var index = letters.indexOf(letter);
@dcabines
dcabines / App.Utils.Array
Created July 16, 2015 19:06
array stuff.
App.Utils.Array = (function () {
'use strict';
var utils = {
// TESTED
// check to see if a value is one of any of the supplied values
anyValue: function (value, values) {
return this.any(values, function (item) {
return item === value;
});
@dcabines
dcabines / Plaindrome
Created May 9, 2014 16:23
Know it. Memorize it.
/// <summary>
/// Determines whether the string is a palindrome.
/// </summary>
public static bool IsPalindrome(string value) {
int min = 0;
int max = value.Length - 1;
while (true) {
if (min > max) {
return true;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Data.SqlClient;
namespace Greenshades.Online.Data.Settings {
@dcabines
dcabines / TopWords.cs
Last active December 16, 2015 13:48
List the top words used in a file and the number of times they are used.
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace TopWords {
internal class Program {
private static void Main(string[] args) {
const int maxWords = 298;
const int minWordLength = 4;
public bool ExportWorkbookToPdf(string workbookPath, string outputPath)
{
// If either required string is null or empty, stop and bail out
if (string.IsNullOrEmpty(workbookPath) || string.IsNullOrEmpty(outputPath))
{
return false;
}
// Create COM Objects
Microsoft.Office.Interop.Excel.Application excelApplication;
@dcabines
dcabines / Cloud-Storage-Prices.js
Created November 18, 2012 00:59
Prices of Cloud Storage Line Chart. Paste it into the Google Code Playground. See an example at http://i.imgur.com/p7QqV.png
// Amazon Glacier has a 3 to 5 hour access time.
// Glacier Archive and Restore Requests are $0.05 per 1,000 requests
// Glacier is designed with the expectation that restores are infrequent and unusual, and data will be stored for extended periods of time.
// You can restore up to 5% of your average monthly Glacier storage (pro-rated daily) for free each month.
// If you choose to restore more than this amount of data in a month, you are charged a restore fee starting at $0.01 per gigabyte.
// Amazon charges 0.01 per 1,000 requests (10,000 for GET requests).
// Azure charges 0.01 per 100,000 transactions.
// To make the Azure and Amazon lines not overlap, I added one one hundredth of a penny to the Amazon prices.
@dcabines
dcabines / CookieHelp.cs
Created October 16, 2012 17:48
CookieHelp
using System;
using System.Web;
using System.Collections.Specialized;
namespace WebData {
public static class CookieHelp {
public static void Add(string name, DateTime expiration, NameValueCollection data) {
var cookie = new HttpCookie(name) {Expires = expiration};
foreach (string key in data.Keys) cookie[key] = data[key];
HttpContext.Current.Response.Cookies.Add(cookie);