Skip to content

Instantly share code, notes, and snippets.

View BenjaminAdams's full-sized avatar
🤠
wrangling up the codes at the wild west corral

Benjamin Adams BenjaminAdams

🤠
wrangling up the codes at the wild west corral
  • Austin, Tx
View GitHub Profile
/*******************************************************
# * By Gunner Technology contact@gunnertech.com
# *
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version as long as your provide attribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@BenjaminAdams
BenjaminAdams / CountryCodeConverter.cs
Last active February 16, 2021 15:35
C# convert two letter country codes to three letter country codes
public static class CountryCodeConverter
{
public static string ConvertThreeLetterNameToTwoLetterName(string twoLetterCountryCode)
{
if (twoLetterCountryCode == null || twoLetterCountryCode.Length != 2)
{
throw new ArgumentException("name must be three letters.");
}
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
@robertsdionne
robertsdionne / deepdream-install.md
Last active February 15, 2021 16:07
Deepdream installation
#!/usr/bin/env bash

# Assuming OS X Yosemite 10.10.4

# Install XCode and command line tools
# See https://itunes.apple.com/us/app/xcode/id497799835?mt=12#
# See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
xcode-select --install
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@BenjaminAdams
BenjaminAdams / upload.js
Created October 1, 2013 07:15
Upload image and/or a file with Javascript
uploadImg: function(file, imgPreview, imgUrl) {
var self = this
console.log('file=', file)
imgPreview.html('<i class="icon-spinner icon-spin"></i>')
imgUrl.val('')
reader = new FileReader();
reader.onload = (function(tFile) {
return function(evt, response) {
@TooTallNate
TooTallNate / node-agent-false-assertion-failure.js
Created September 8, 2013 17:28
node v0.11.7 Assertion Failure, caused by HTTP `agent: false`
var url = require('url');
var http = require('http');
var uri = 'http://nodejs.org';
var parsed = url.parse(uri);
parsed.method = 'GET';
// IMPORTANT!
parsed.agent = false;
@BenjaminAdams
BenjaminAdams / index.html
Created May 31, 2013 17:16
The iframe upload trick - How to upload files without refreshing the page by submitting the file through a hidden iframe.
<div id='status'></div>
<form id="file-upload-form" name="file-upload-form">
<input type="file" id="upload-doc-file" name="upload-doc-file">
</form>
<iframe id="postiframe" name="postiframe"></iframe>
@amoilanen
amoilanen / webcrawler.js
Last active March 24, 2022 03:14
Simple PhantomJS-based web crawler library
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 2012
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler"
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist
(function(host) {
function Crawler() {
this.visitedURLs = {};
};