Skip to content

Instantly share code, notes, and snippets.

View ismaelhamed's full-sized avatar
🚀
lezduit

Ismael Hamed ismaelhamed

🚀
lezduit
  • Schneider Electric
  • Spain
  • 03:51 (UTC +01:00)
View GitHub Profile
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_multiTenant');
/**
* User schema.
*/
var UserSchema = new mongoose.Schema({
name: String
, prefix: { type: String, required: true }
using Telerik.Windows.Controls;
namespace System.Windows.Interactivity
{
public class PullToRefreshBehavior : Behavior<RadDataBoundListBox>
{
/// <summary>
/// Gets or sets a value indicating whether the RefreshLabel in the PullToRefreshLoading indicator should be updated.
/// </summary>
public bool UpdateRefreshLabel { get; set; }
@ismaelhamed
ismaelhamed / IEnumerableExtensions
Created May 17, 2013 14:18
Collection of extensions methods for IEnumerable
public static class IEnumerableExtensions
{
/// <summary>
/// Batches up an enumerable and yields you a sequence of arrays.
/// </summary>
public static IEnumerable<T[]> Batch<T>(this IEnumerable<T> sequence, int batchSize)
{
var batch = new List<T>(batchSize);
foreach (var item in sequence)

NPM Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

##List of less common (however useful) NPM commands

######Install a package and also update package.json with the installed version and package name.

@ismaelhamed
ismaelhamed / NameValueCollection.cs
Last active March 27, 2018 11:34
Represents a collection of associated String keys and String values that can be accessed either with the key or with the index. Portable version.
namespace System.Collections.Specialized
{
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Represents a collection of associated String keys and String values that can be accessed either with the key
/// or with the index.
/// </summary>
public class NameValueCollection : IEnumerable<KeyValuePair<string, string>>
@ismaelhamed
ismaelhamed / NameValueCollectionExtensions.cs
Last active December 25, 2015 02:49
Some extension methods for the object NameValueCollection
namespace System.Collections.Specialized
{
using System.Collections.Generic;
using System.Linq;
using System.Net;
public static class NameValueCollectionExtensions
{
public static IDictionary<string, string> ToDictionary(this NameValueCollection source)
{
@ismaelhamed
ismaelhamed / UnixDateTimeConverter.cs
Last active January 2, 2016 12:48
*NIX Epoch integer converter for DateTime
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public class UnixDateTimeConverter : DateTimeConverterBase
{
/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
@ismaelhamed
ismaelhamed / FacadesExtensions.cs
Last active August 29, 2015 13:56
Telerik's Everlive SDK for Windows Phone 7.5 is missing ExecuteAsync and TryExecuteAsync methods, and thus support for await/async calls.
using System.Threading.Tasks;
using Telerik.Everlive.Sdk.Core.Result;
namespace Telerik.Everlive.Sdk.Core.Facades
{
public static class FacadesExtensions
{
public static Task<T> ExecuteAsync<T>(this AsyncFacade<T> facade)
{
var tcs = new TaskCompletionSource<T>();
@ismaelhamed
ismaelhamed / PasswordCredential.cs
Last active August 29, 2015 14:01
PasswordVault class implementation for Windows Phone (Silverlight)
using System;
using System.Collections.Generic;
#if WINDOWS_PHONE_8
namespace Windows.Security.Credentials
#else
namespace System.Security.Credentials
#endif
{
/// <summary>
@ismaelhamed
ismaelhamed / HtmlExtensions.cs
Last active August 29, 2015 14:03
Leveraging AngularJS built-in XSRF protection with ASP.NET MVC
using System.Web.Helpers;
namespace System.Web.Mvc
{
public static class HtmlExtensions
{
const string AntiForgeryCookieName = "XSRF-TOKEN";
public static IHtmlString AngularJSAntiForgeryToken(this HtmlHelper html)
{