Skip to content

Instantly share code, notes, and snippets.

View narainsagar's full-sized avatar
👋
email me for projects or relocation roles!!

Narain M. narainsagar

👋
email me for projects or relocation roles!!
View GitHub Profile
@narainsagar
narainsagar / mailchimp_3.0.php
Last active June 11, 2023 08:59
How to Dynamically send a newsletter with MailChimp 3.0 via PHP
<?php
/**
* Reference Links:
* - https://mailchimp.com/help/find-your-list-id/
* - https://stackoverflow.com/a/48655086/5228251
* - https://thedebuggers.com/send-mailchimp-newsletter-via-php/
*/
// Include Mailchimp API 3.0
@narainsagar
narainsagar / ca.md
Created July 9, 2018 21:04 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@narainsagar
narainsagar / .bash_profile
Created February 22, 2018 18:49 — forked from stephenll/.bash_profile
.bash_profile file on Mac OS X
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases.
# Much of this was originally copied from:
# http://natelandau.com/my-mac-osx-bash_profile/
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
@narainsagar
narainsagar / onpubcom_array_date_sort.js
Created November 9, 2017 11:44 — forked from onpubcom/onpubcom_array_date_sort.js
How to Sort an Array of Dates with JavaScript
<script type="text/javascript">
// First let's create an array of JavaScript Date
// objects.
// More info about the Date class:
// http://w3schools.com/js/js_obj_date.asp
var dates = [
new Date(2010, 4, 10, 10, 07, 16),
new Date(2010, 4, 8, 9, 16, 09),
new Date(2010, 3, 30, 0, 15, 49),
@narainsagar
narainsagar / http-status-codes.md
Created November 7, 2017 15:53 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@narainsagar
narainsagar / angular4-advanced-routing-notes.md
Last active June 1, 2018 23:30
Code snippets for talk on Angular4 Advanced Routing, slides are here: https://goo.gl/N8DneM

Basic Routing

import { ChildRoutes } from './child.routes';

const APP_ROUTES: Routes = [
    { path: '', redirectTo: 'login', pathMatch: 'full' },
    { path: 'login', component: LoginComponent },
    { path: 'register', component: RegisterComponent },
    { path: 'dashboard', component: DashboardComponent },
@narainsagar
narainsagar / emoji
Created February 11, 2017 23:27 — forked from itsthatguy/emoji
All the emoji characters available for easy copy and paste (copy and paste into your favorite editor)
😁 😂 😃 😄 😅 😆 😉 😊 😋 😌 😍 😏 😒 😓 😔 😖 😘 😚 😜 😝 😞 😠 😡 😢 😣
😤 😥 😨 😩 😪 😫 😭 😰 😱 😲 😳 😵 😷 😸 😹 😺 😻 😼 😽 😾 😿 🙀 🙅 🙆 🙇
🙈 🙉 🙊 🙋 🙌 🙍 🙎 🙏 ✂ ✅ ✈ ✉ ✊ ✋ ✌ ✏ ✒ ✔ ✖ ✨ ✳ ✴ ❄ ❇ ❌
❎ ❓ ❔ ❕ ❗ ❤ ➕ ➖ ➗ ➡ ➰ 🚀 🚃 🚄 🚅 🚇 🚉 🚌 🚏 🚑 🚒 🚓 🚕 🚗 🚙
🚚 🚢 🚤 🚥 🚧 🚨 🚩 🚪 🚫 🚬 🚭 🚲 🚶 🚹 🚺 🚻 🚼 🚽 🚾 🛀 Ⓜ 🅰 🅱 🅾 🅿
🆎 🆑 🆒 🆓 🆔 🆕 🆖 🆗 🆘 🆙 🆚 🇩🇪 🇩🇪 🇩🇪 🇬🇧 🇬🇧 🇬🇧 🇨🇳 🇨🇳 🇨🇳 🇯
🇵 🇯🇵 🇯🇵 🇰🇷 🇰🇷 🇰🇷 🇫🇷 🇫🇷 🇫🇷 🇪🇸 🇪🇸 🇪🇸 🇮🇹 🇮🇹 🇮🇹 🇺🇸 🇺🇸
🇺🇸 🇷🇺 🇷🇺 🇷🇺 🈁 🈂 🈚 🈯 🈲 🈳 🈴 🈵 🈶 🈷 🈸 🈹 🈺 🉐 🉑 © ® ‼ ⁉
#⃣ #⃣ #⃣ ™ ℹ ↔ ↕ ↖ ↗ ↘ ↙ ↩ ↪ ⌚ ⌛ ⏩ ⏪ ⏫ ⏬ ⏰ ⏳ ▪ ▫ ▶
◀ ◻ ◼ ◽ ◾ ☀ ☁ ☎ ☑ ☔ ☕ ☝ ☺ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓
@narainsagar
narainsagar / download.md
Created December 8, 2016 15:37
Download a file with custom data and filename into browser (via Pure JS)

Define below method:

i.e., I have created this for my angular2 app. so this function is written in TypeScript

  createDownloadLink(filename: string, data: string) {
    var dataUri = 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(data);
    var anchor = document.createElement('a');

 anchor.setAttribute('href', dataUri);
@narainsagar
narainsagar / order_array.js
Last active November 20, 2016 22:32
Order Array of data based on activeIndex and clickedIndex elements.. (i.e., Images slider example)
/**
* Order Array of data based on single data...
* IDEA:
In Images Slider example we'd have collection of images data and one one image will be shown as default active (to be shown always).
Now when we click on anyother image that will be active and other images will be ordered according. we will be order all images in a way that
all images will be viewing in cycle (from both sides).
**/
/**
@narainsagar
narainsagar / ordinal.js
Created November 15, 2016 21:33
Ordinal numbers
function ordinalParse() {
return /\d{1,2}(st|nd|rd|th)/;
}
function ordinal(number) {
var b = number % 10,
output = (~~(number % 100 / 10) === 1) ? 'th' :
(b === 1) ? 'st' :
(b === 2) ? 'nd' :
(b === 3) ? 'rd' : 'th';