Skip to content

Instantly share code, notes, and snippets.

@ssajous
ssajous / API.md
Created August 27, 2014 16:45 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

  1. Open Terminal move to your home folder: cd ~

  2. Enable git colors: git config --global color.ui true

  3. Make a file called ".colors": touch .colors

  4. Open .colors and paste the following:

@ssajous
ssajous / analyticsService.js
Last active August 29, 2015 14:01
Setting up a google analytics service in an angularjs application
var myModule = angular.module('myModule', []);
myModule.factory('googleAnalytics', ['$window', function($window) {
// Initialize GA Tracker
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
ko.dirtyFlag = function(root, isInitiallyDirty) {
var result = function() {},
_initialState = ko.observable(ko.toJSON(root)),
_isInitiallyDirty = ko.observable(isInitiallyDirty),
_initialized = ko.observable(false);
result.isDirty = ko.computed(function() {
return _initialized() && (_isInitiallyDirty() || _initialState() !== ko.toJSON(root));
});
// tooltip binding
// usage: data-bind="tooltip: { title: 'My tooltip text', trigger: 'hover click', placement: 'right'}"
ko.bindingHandlers.tooltip = {
init: function (element, valueAccessor) {
var options = ko.utils.unwrapObservable(valueAccessor());
$(element).tooltip(options);
},
};
@ssajous
ssajous / overlayMessage.js
Created December 17, 2013 16:05
Knockout custom binding to display a message overlaid above a div
ko.bindingHandlers.overlayMessage = {
init: function(element, valueAccessor) {
},
update: function(element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
if (value !== '') {
var overlayStyles = {
height: $(element).outerHeight(),
width: $(element).outerWidth(),
@ssajous
ssajous / AzureMobileServiceGenericCRUD.js
Last active December 25, 2015 08:29
Javascript generic REST client to Azure Mobile Services for basic CRUD operations.
var httpVerbs = {
POST: 'POST',
PUT: 'PUT',
PATCH: 'PATCH',
GET: 'GET',
DEL: 'DELETE'
};
var constants = {
// Should be your application specific key for Azure
@ssajous
ssajous / FB.html
Last active December 21, 2015 14:58
<!--
Import the Facebook API javascript. FB examples load this dynamically through jquery, but this avoids
any ajax caching issues.
-->
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
@ssajous
ssajous / IStringSerializer.cs
Created August 23, 2013 03:17
Components to generate secure tokens to be created by a secure web service to use for authentication of subsequent calls. It essentially operates on the same premise of a remember me cookie in forms authentication. The token expiration should use configured values instead of hard coding... This example uses JSON .NET to serialize objects into js…
public interface IStringSerializer
{
T Deserialize<T>(string item);
string Serialize(object item);
}
@ssajous
ssajous / DelimStringToIntTable.sql
Created July 26, 2013 15:37
Takes a string of comma delmited integer values and splits them into a table which can be joined into other queries.
CREATE FUNCTION [dbo].[DelimStringToIntTable](@input AS VARCHAR(MAX))
RETURNS
@Result TABLE(ID BIGINT)
AS
BEGIN
DECLARE @str VARCHAR(20)
DECLARE @ind Int
IF(@input is not null)
BEGIN