Skip to content

Instantly share code, notes, and snippets.

View Sinetheta's full-sized avatar

Kevin Attfield Sinetheta

View GitHub Profile
### Keybase proof
I hereby claim:
* I am sinetheta on github.
* I am sinetheta (https://keybase.io/sinetheta) on keybase.
* I have a public key ASBB3vf88ZLQjHDf7HO4FwtmvxTXWghhzjn-1EK2q58YHAo
To claim this, I am signing this object:
# A script to help setup S3 for new projects using aws sdk
#
# - Create new S3 bucket <prompt for bucket name>
# - [optional] configure bucket as website
# - [optional] configure bucket as publicly readable
# - Create new IAM user <prompt for user name>
# - Create new customer managed policy for full S3 access to new bucket only
# - Attach policy directly to new user
# - Create and print API access keypair
#
@Sinetheta
Sinetheta / order_completed.erb
Created November 10, 2016 04:16
segment order complete
<script>
analytics.track('Order Completed', {
order_id: '<%= j order.number %>',
affiliation: '<%= current_store.name %>',
total: '<%= order.total %>',
shipping: '<%= order.ship_total %>',
tax: '<%= order.tax_total %>',
discount: '<%= (- order.promo_total) %>',
coupon: '<%= order.coupon_code %>',
currency: '<%= order.currency %>',
@Sinetheta
Sinetheta / promisify.js
Created October 4, 2016 07:04
A jquery plugin for wrapping a function with a promise
// Wrap a function and return a promise instead of accepting a callback.
//
// @param target [Function] the function to be wrapped. This function *must*
// accept a callback as its last argument of the form `function(err, data) {}`.
// @param args [Array] an array of the arguments for the target function.
// Not including the final callback, which will be provided by promisify.
// @return [Promise] A jQuery promise object which will resolve or reject
// based on the arguments passed to the callback.
function promisify(fun, args, self) {
var d = $.Deferred();
@Sinetheta
Sinetheta / custom-matchers.coffee
Last active August 29, 2015 14:22
custom-matchers.coffee
customMatchers =
toChange: (util, customEqualityTesters) ->
compare: (actual, expected) ->
before = expected()
actual()
after = expected()
result =
pass: !util.equals(before, after, customEqualityTesters)
if result.pass
result.message = "Expected result not to change, but went from #{before} to #{after}"
@Sinetheta
Sinetheta / footnoteLinks.js
Last active December 23, 2015 09:09
Add a footnotes style list of links at the bottom of a page. Hide with class `.printOnly`. Depending on your environment, it may be necessary to scope the target container (eg: avoid including navigation links).
@Sinetheta
Sinetheta / master.master
Last active December 22, 2015 02:09
Exposing user data through javascript on a SharePoint 2010 master page.
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SPSWC:ProfilePropertyLoader runat="server"/>
<script>
CurrentUser = {
UserName: '<SPSWC:ProfilePropertyValue PropertyName="UserName" TitleMode="true" runat="server" />',
FirstName: '<SPSWC:ProfilePropertyValue PropertyName="FirstName" TitleMode="true" runat="server" />',
Lastname: '<SPSWC:ProfilePropertyValue PropertyName="LastName" TitleMode="true" runat="server" />',
PictureURL: '<SPSWC:ProfilePropertyValue PropertyName="PictureURL" TitleMode="true" runat="server" />',
@Sinetheta
Sinetheta / README.md
Last active July 14, 2016 13:45
Using Yeoman to make a SharePoint 2010 project with REST.

Setting up a new Yeoman project using the sp2010 rest emulator:

  1. Create a new Yeoman project, eg: $ yo webapp my-project.
  2. Install the SharePoint 2010 rest emulator $ npm install sp2010-rest --save-dev.
  3. Add the rest emulator as middleware to any connect servers in your project's [Gruntfile.js][Gruntfile].
  4. Create a 'lists' folder in your project, and fill it with a copy of the json REST response (eg: /_vti_bin/listdata.svc/Documents -> [demo-list.json][json]) for any SharePoint lists you would like to emulate.

Deploying a Yeoman project to a sp2010 server:

  1. Map a network drive to SharePoint.
@Sinetheta
Sinetheta / image-utilities.js
Created May 15, 2013 15:28
image related utilities
function trimExtension(str) {
return str.substr(0, str.lastIndexOf('.'));
}
@Sinetheta
Sinetheta / _.templateSettings.js
Created May 10, 2013 20:10
Underscore templates with moustaches
_.templateSettings = {
evaluate : /\{\[([\s\S]+?)\]\}/g,
interpolate : /\{\{([\s\S]+?)\}\}/g
};