Skip to content

Instantly share code, notes, and snippets.

View code-atom's full-sized avatar
🏠
Working from home

Ankit Rana code-atom

🏠
Working from home
View GitHub Profile
@code-atom
code-atom / MultipleNestingPromise.js
Created January 19, 2017 11:02
Understand the nested promise
var app = angular.module('app',[]);
app.run(function ($http, $q) {
getExample($q)
.then(function(value){
console.log(value);
});
})
function getExample($q) {
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using ClassLibraries.SiteSettings.Classes;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
"use strict";
const { addObserver, notifyObservers } = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const { getEnumerator } = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
const isBrowser = window => {
try {
return window.document.documentElement.getAttribute("windowtype") === "navigator:browser";
@code-atom
code-atom / IpAddressToLocation.cs
Created February 22, 2017 09:45
Find the IPAddress to Location
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@code-atom
code-atom / IndexedDBCRUD.html
Created February 23, 2017 12:41
CRUD operation in IndexDb
<!DOCTYPE html5>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.main-container {
}
</style>
public static string GenerateSEOFriendlyUrl(string uncleanUrl)
{
//Trim Start and End Spaces.
uncleanUrl = uncleanUrl.Trim();
//Trim "-" Hyphen
uncleanUrl = uncleanUrl.Trim('-');
uncleanUrl = uncleanUrl.ToLower();
char[] chars = @"$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray();
//Replace . with - hyphen
uncleanUrl = uncleanUrl.Replace(".", "-");
@code-atom
code-atom / FCMAPINotification.cs
Created March 10, 2017 06:13
FCM Notification based on API
public class Notifications
{
public string SendNotification(GcmNotiInputModel model)
{
try
{
string GoogleAppID = Config.BrowserKey;
var SENDER_ID = Config.SenderId;
@code-atom
code-atom / EmailProvider.cs
Last active April 7, 2017 04:15
Email Provider for sending email
public class EmailProvider : IEmailProvider
{
private readonly SmtpClient smtpClient = null;
private readonly IEmailTemplateRepository _emailRepository;
private bool disposed = false;
private EmailProvider()
{
smtpClient = new SmtpClient();
}
@code-atom
code-atom / listExtension.cs
Created April 14, 2017 12:59
List Intersect Method Extension.
public static class ListExtension
{
public static IEnumerable<TObject> Intersect<TObject>(this IEnumerable<TObject> source, IEnumerable<TObject> destination, Func<TObject, TObject, bool> predicate)
{
var result = new List<TObject>();
foreach (var sourceObject in source)
{
foreach (var destinationObject in destination)
{
if (predicate(sourceObject, destinationObject))
@code-atom
code-atom / CandidateSignatureHandler.cs
Created April 20, 2017 09:24
Custom Http Handler Example
public class CandidateSignatureHandler : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
ICandidateDocument _candidateDocHandler = AppDefaults.Get<ICandidateDocument>();