Skip to content

Instantly share code, notes, and snippets.

View ardeshireshghi's full-sized avatar

Ardeshir Eshghi ardeshireshghi

View GitHub Profile
@ardeshireshghi
ardeshireshghi / limitCalls.js
Created April 28, 2016 15:57
Be able to call a function limited number of times
function limitCalls(fn, maxCall) {
if (!fn.called) {
fn.called = 0;
}
return function() {
if (fn.called < maxCall) {
fn.called++;
return fn.apply(null, arguments);
}
@ardeshireshghi
ardeshireshghi / serialisedQueryParser.js
Created May 5, 2016 17:49
Custom queryparam parser
var http = require('http');
var qs = require('querystring');
function parseSerialisedQueryParam(request, paramName, delimiter) {
delimiter = delimiter || ',';
var url = request.url;
var rawQuery = require('url').parse(url).query;
var parsedQuery = qs.parse(rawQuery, null, null, {
decodeURIComponent: function(param) {
return param;
function inherits(constructor1, constructor2) {
constructor1.prototype = extend(constructor2.prototype);
}
function objectEmpty(obj) {
return Object.keys(obj).length === 0 && obj.constructor === Object;
}
function extend() {
var i = -1,
current,
@ardeshireshghi
ardeshireshghi / modal.html
Last active August 18, 2016 18:38
Cool CSS3/JS modal
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Raleway:400,700,500' rel='stylesheet' type='text/css'>
<style type="text/css">
html {
height: 100%;
position: relative;
Array.isEqual = function(a, b) {
if (a === b) {
return true;
}
// We do not expect string arguments
if (typeof a === 'string' || typeof b === 'string') {
return false;
}
// We need array like arguments (e.g. NodeList)
@ardeshireshghi
ardeshireshghi / lodash.hasKeyDeep.js
Created October 14, 2016 11:21
Deep check if an object has a key
const hasKeyDeep = ((_) => {
return (object, keyName) => {
let hasKey = false;
if (_.has(object, keyName)) {
return true;
}
_.forEach(object, (value) => {
if (_.isObject(value)) {
hasKey = hasKeyDeep(value, keyName);
* aws_cloudfront_distribution.s3_ui_distribution: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
Please include the following information in your report:
Terraform Version: 0.7.13
Resource ID: aws_cloudfront_distribution.s3_ui_distribution
Mismatch reason: attribute mismatch: origin.874400726.custom_header.#
Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"http_version":*terraform.ResourceAttrDiff{Old:"", New:"http2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "default_cache_behavior.948431832.default_ttl":*terraform.ResourceAttrDiff{Old:"", New:"3600", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "default_cache_behavior.948431832.min_ttl":*terraform.ResourceAttrDiff{Old:"", New:"0", NewComputed:false, NewRemoved:
@ardeshireshghi
ardeshireshghi / python-dict-to-js-object.js
Created December 22, 2016 17:25
Added some of the dict python api to JS Object type
;((Object) => {
Object.prototype.keys = Object.prototype.keys || function() {
return Object.keys(this);
}
Object.prototype.values = Object.prototype.values || function() {
return this.keys().map(key => this[key]);
}
Object.prototype.items = Object.prototype.items || function() {
<!DOCTYPE html>
<html>
<head>
<title>JPG to PNG</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
height: 100%;
text-align: center;
Function.prototype.bind = Function.prototype.bind || function() {
var args = Array.prototype.slice.call(arguments);
var context = args[0];
var fn = this;
return function() {
var fnArgs = Array.prototype.slice.call(arguments);
fn.apply(context, args.slice(1).concat(fnArgs));
}
}