Skip to content

Instantly share code, notes, and snippets.

View AshikNesin's full-sized avatar

Ashik Nesin AshikNesin

View GitHub Profile
@AshikNesin
AshikNesin / serializeObject.js
Created November 8, 2016 07:52
Serialize Object using jQuery
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
@AshikNesin
AshikNesin / unhandled-exceptions.js
Created November 6, 2016 18:59 — forked from ericelliott/unhandled-exceptions.js
Capturing Unhandled Exceptions
window.onerror = function(message, file, line, column, error) {
error = error || {};
$.ajax({
method: 'POST',
url: 'https://yourapp.com/path/to/error/log',
data: JSON.stringify({
message: message,
file: file,
line: line,
column: column,
@AshikNesin
AshikNesin / default-ssl.conf
Last active October 27, 2016 13:11
Apache SSL Config
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/__optacredit_com.crt
SSLCertificateKeyFile /etc/apache2/ssl/optacredit.com.key
SSLCACertificateFile /etc/apache2/ssl/__optacredit_com.ca-bundle
ServerAdmin [email protected]
ServerName optacredit.com
DocumentRoot /var/www/html/
#ErrorLog /var/www/yourdomain.com/logs/error.log
#CustomLog /var/www/yourdomain.com/logs/access.log combined
@AshikNesin
AshikNesin / mailchimp-single-optin.php
Created October 24, 2016 06:40
MailChimp Single Optin
<?php
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
// switch ($_SERVER['HTTP_ORIGIN']) {
// case 'http://www.ios.buyselltickets.in': case 'http://ios.buyselltickets.in':
// header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
// header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
// header('Access-Control-Max-Age: 1000');
// header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
// break;

This let's me git clone a template repo, cd into and fire up a new template in my editor of choice:

$ clone starter # clones https://github.com/addyosmani/starter (a personal boilerplate)

$ clone h5bp html5-boilerplate # get me HTML5 Boilerplate

$ clone angular angular-seed # same for AngularJS seed

$ clone polymerlabs seed-element # same for a new Polymer element
@AshikNesin
AshikNesin / product.py
Created August 18, 2016 12:43
Scrape Product details from Amazon.com, FlipKart
import requests
import json
import re
from bs4 import BeautifulSoup
""" TODO
- Offers and its price
"""
def query_string_remove(url):
@AshikNesin
AshikNesin / $.3.js
Created August 6, 2016 13:38 — forked from ofca/$.3.js
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
@AshikNesin
AshikNesin / date.utils.js
Created July 28, 2016 10:52
[JS] Implicit Convert HH:MM:SS to Date Object
function toDateWithOutTimeZone(date) {
let tempTime = date.split(":");
let dt = new Date();
dt.setHours(tempTime[0]);
dt.setMinutes(tempTime[1]);
dt.setSeconds(tempTime[2]);
return dt;
}
@AshikNesin
AshikNesin / multiple-3rd-party-widgets.js
Created July 16, 2016 10:53 — forked from zenorocha/multiple-3rd-party-widgets.js
Loading multiple 3rd party widgets asynchronously
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@AshikNesin
AshikNesin / CurrencyExchange.py
Created May 1, 2016 15:01
USD to INR Currency Exchange Scraping
import requests
import re
from bs4 import BeautifulSoup
from decimal import Decimal
def USD_to_INR(USD):
'''
- Retrieve last updated and convertion from db
- If latest update is less than 24 hours then make is_latest True