Skip to content

Instantly share code, notes, and snippets.

View SafeerH's full-sized avatar

Safeer Hussain SafeerH

View GitHub Profile
@SafeerH
SafeerH / js-smooth-scroll.js
Last active August 29, 2015 14:05
Smooth scroll to an element with jQuery
/// Usage: (HTML)
///
/// <a data-smooth-scroll href="#section1">Section 1</a>
///
/// <div id="section1">This is section 1</div>
$(document).ready(function() {
$('a[href^="#"][data-smooth-scroll]').on('click', function(event) {
@SafeerH
SafeerH / css-scroll-shadow.css
Last active August 29, 2015 14:05
Show the top and bottom inset-shadows to a scrollable div
.scrollbox {
overflow: auto;
width: 200px;
max-height: 200px;
margin: 50px auto;
background:
/* Shadow covers */
linear-gradient(white 30%, rgba(255,255,255,0)),
linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
@SafeerH
SafeerH / DelayedTrigger.cs
Last active August 29, 2015 14:07
Delayed Trigger (trigger event after 1 second)
public partial class Form1 : Form
{
private DateTime _lastScrollEvent = new DateTime(0);
private async void DetectShapeAsync()
{
labelUTVal.Text = (trackBarUniquenessThreshold.Value / 100d).ToString();
labelHTVal.Text = trackBarHessianThresh.Value.ToString();
_lastScrollEvent = DateTime.Now;

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@SafeerH
SafeerH / XmlHelper.cs
Created November 26, 2014 06:21
C# ToXml and FromXml
public static class FormattingExtensions
{
public static string ToXml(this object o)
{
XmlSerializer serializer = new XmlSerializer(o.GetType());
using (StringWriter writer = new StringWriter())
{
serializer.Serialize(writer, o);
return writer.ToString();
}
@SafeerH
SafeerH / EmailService.cs
Created May 20, 2015 05:48
Simple SMTP Email Service [for ASP.NET 5 (vNext)]
using System;
using System.Net.Mail;
using Microsoft.Framework.ConfigurationModel;
namespace Mzmsh.SimpleSmtpEmail
{
public class EmailService
{
private readonly IConfiguration _config;
private readonly EmailSettings _settings;
@SafeerH
SafeerH / JsStringExtensions.js
Last active August 29, 2015 14:23
JavaScript Extensions (String.Format)
/* Format strings in JavaScript
* Usage:
* > "Hello {0}!".format('Safeer'); // Hello Safeer!
*
* > var str = "{0} is one of the most popular programming languages in the world. \
* This {1} contains some extension methods that can be used in your {0} code.";
* str.format('JavaScript', 'Gist');
*
*/
String.prototype.format = function() {
@SafeerH
SafeerH / GetQueryString.js
Created September 7, 2015 11:49
Get query string from JavaScript
function getQueryString() {
var result = {}, queryString = location.search.slice(1),
re = /([^&=]+)=([^&]*)/g, m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
}
@SafeerH
SafeerH / same-password.directive.js
Created February 22, 2016 17:08
`samePassword` is a directive with the purpose to validate a password input based on the value of another input. When both input values are the same the inputs will be set to valid.
(function() {
'use strict';
angular
.module('triangular.directives')
.directive('triSamePassword', samePassword);
/* @ngInject */
function samePassword() {
// Usage: