Skip to content

Instantly share code, notes, and snippets.

View benjamincharity's full-sized avatar
🤖

Benjamin Charity benjamincharity

🤖
View GitHub Profile
@benjamincharity
benjamincharity / filter.sentanceCase.coffee
Created February 28, 2014 17:46
Sentance case filter for Angular. Solution below requires Underscore.js
myModule.filter "sentence_case", ->
_.memoize (x) ->
return unless angular.isString(x)
x = x.toLowerCase()
capitalize = (str) ->
str += ''
return str.charAt(0).toUpperCase() + str.slice(1)
fmt = (y) ->
capitalized = capitalize($.trim(y))
@benjamincharity
benjamincharity / master.vim
Last active September 10, 2024 14:26 — forked from gmccreight/master.vim
Master Vim with this interactive tutorial.
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@benjamincharity
benjamincharity / spotijay_error
Created January 27, 2015 12:51
An error seen while getting Spotijay up and running.
/Users/bc/Dropbox/Projects/open-source/Spotijay/node_modules/libspotify/node_modules/bindings/bindings.js:83
throw e
^
Error: dlopen(/Users/bc/Dropbox/Projects/open-source/Spotijay/node_modules/libspotify/build/Release/spotify.node, 1): Library not loaded: /usr/local/opt/libspotify/lib/libspotify
Referenced from: /Users/bc/Dropbox/Projects/open-source/Spotijay/node_modules/libspotify/build/Release/spotify.node
Reason: image not found
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
@benjamincharity
benjamincharity / validation.rule.js
Created March 5, 2015 12:21
Validation rules for the Angular Validation library - https://github.com/huei90/angular-validation/ .
/* jshint regexdash: false */
(function() {
angular.module('validation.rule', ['validation'])
.config(['$validationProvider', function($validationProvider) {
var expression = {
required: function(value) {
return !!value;
},
url: /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/,
@benjamincharity
benjamincharity / contacts.js
Last active January 9, 2023 16:06
Create a downloadable file of VCARD formatted address for iOS from a JSON array.
var contacts =
[
{
"notes": [
{
"description": "Fugiat aute pariatur excepteur elit."
}
],
"tels": [
{
@benjamincharity
benjamincharity / iosContactTemplate.js
Created May 8, 2015 14:14
JSON generator template for iOS contact creation
[
"{{repeat(100, 100)}}",
{
"fn":{
"name":"{{firstName()}} {{surname()}}"
},
"n":{
"families":"{{surname()}}",
"givens":"{{firstName()}}"
},
@benjamincharity
benjamincharity / centsToDollars.js
Created May 19, 2015 13:20
Convert cents to dollars.
angular.module('MyModule')
.filter('dollars', function() {
return function(input) {
return '$' + parseInt(input, 10) / 100;
};
});
@benjamincharity
benjamincharity / cardFlip.scss
Last active December 7, 2015 14:25
Styles to create a flippable card.
/////////////////////////////////////////////
//
// Flipable Card
//
// Markup:
// .flip
// .flip__inner
// .front
// .back
@benjamincharity
benjamincharity / manageBucket.json
Created May 20, 2015 17:36
List all Amazon S3 buckets and allow management of a single bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::my.bucket.com",
"arn:aws:s3:::my.bucket.com/*"
]
@benjamincharity
benjamincharity / s3BucketPolicy.json
Last active December 19, 2016 15:31
Amazon S3 bucket policy for static site.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",