Skip to content

Instantly share code, notes, and snippets.

View akanieski's full-sized avatar

Andrew Kanieski akanieski

View GitHub Profile
@akanieski
akanieski / currency.js
Created October 18, 2013 22:43
AngularJS Decimal Only Directive
angular.module('myApp.directives', []).directive('currency', function () {
return {
restrict: 'A',
transclude: false,
require: '^ngModel',
scope: false,
controller: function ($scope, $element, $attrs) {
$scope.$watch($attrs.ngModel, function (newValue, oldValue) {
var val = newValue.toString().replace(/[^\d.-]/g, '');
val = val.length > 0 ? val : '""';
@akanieski
akanieski / pulse.css
Created October 25, 2013 02:19
CSS3 Pulse Effect
.pulse {
-webkit-animation: pulse 1s linear infinite;
-moz-animation: pulse 1s linear infinite;
-ms-animation-name: pulse 1s linear infinite;
-o-animation-name: pulse 1s linear infinite;
animation-name: pulse 1s linear infinite;
}
@-webkit-keyframes pulse {
@akanieski
akanieski / calculate_business_days.js
Created November 4, 2013 21:01
Business days between two dates
/*
Taken from http://snipplr.com/view.php?codeview&id=4086
*/
function calcBusinessDays(dDate1, dDate2) { // input given as Date objects
var iWeeks, iDateDiff, iAdjust = 0;
if (dDate2 < dDate1) return -1; // error code if dates transposed
var iWeekday1 = dDate1.getDay(); // day of week
@akanieski
akanieski / carrier_domains.json
Created November 22, 2013 23:41
Email to SMS - Carrier Domains
[
{
name: 'Verizon',
domain: 'vtext.com'
},
{
name: 'Sprint',
domain: 'vtext.com'
},
{
@akanieski
akanieski / tsql_email_validation.sql
Created December 3, 2013 19:18
TSQL - Email Validation
select * from people where email not like '%_@_%_.__%'
@akanieski
akanieski / rc4_ascii_extended.js
Created January 20, 2014 15:48
RC4 with support for ASCII Extended (Char Codes > 127)
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<!DOCTYPE html>
<html>
<head>
<title>KHIM Inspections Installation</title>
</head>
<body>
<h2>Release builds</h2>
<a href="itms-services://?action=download-manifest&amp;url=https://dl.dropboxusercontent.com/u/9675825/manifest.plist">KHIM Inspections v0.2.0</a></body>
<h2>Testing builds</h2>
@akanieski
akanieski / slicer.rb
Last active August 29, 2015 14:02 — forked from miletbaker/map_tile.rb
#! /usr/bin/ruby -w
require 'rubygems'
require 'rmagick'
require 'fileutils'
include Magick
puts 'Go!'
limit = ARGV.length > 1 ? ARGV[1].to_i : 18
file = ARGV[0]