Skip to content

Instantly share code, notes, and snippets.

View lusan's full-sized avatar
🎯
Focusing

Lusan Das lusan

🎯
Focusing
View GitHub Profile
@lusan
lusan / SassMeister-input-HTML.html
Created February 5, 2016 12:01
Generated by SassMeister.com.
<div class="container">
<h1>The 10 column complex nested grid AG test</h1>
<div class="ag ag1">
<h2>AG 1</h2>
</div>
<!-- /ag1 -->
<!-- ag4 to ag7 are nested within ag2.-->
<div class="ag ag2">
var inputString = "dilip %s Kumar %s";
var finalString;
function manipulateString(param) {
finalString = inputString;
for(var i = 0; i <= arguments.length; i++) {
finalString = finalString.replace('%s',arguments[i]);
}
return finalString;
}
console.log(manipulateString("is", "cool"));
var counter = 0, // to keep track of current slide
$items = document.querySelectorAll('.slideshow figure'), // a collection of all of the slides, caching for performance
numItems = $items.length; // total number of slides
var ImageSlider = function() {
this.bindEvents.call(this);
};
ImageSlider.prototype.bindEvents = function() {
var self = this;
/* Module to check if two objects are euqal*/
var isObjectsEqual = function(a, b) {
var aProp = Object.getOwnPropertyNames(a);
var bProp = Object.getOwnPropertyNames(b);
if(aProp.length != bProp.length) {
console.log("Objects are not equal");
return false;
}
/*
This piece has been taken from React.js Conf 2015 - Immutable Data and React
*/
function memoize(fn) {
var prevArg;
var prevResult;
return function(arg) {
return arg === prevArg ?
prevResult :
(prevArg = arg,
var measureCRP = function measureCRP() {
var t = window.performance.timing,
interactive = t.domInteractive - t.domLoading,
dcl = t.domContentLoadedEventStart - t.domLoading,
complete = t.domComplete - t.domLoading;
var stats = document.createElement('p');
stats.textContent = 'interactive: ' + interactive + 'ms, ' +
'dcl: ' + dcl + 'ms, complete: ' + complete + 'ms';
document.body.appendChild(stats);
}
export const removeBaseUrl = (url) => {
/*
* Replace base URL in given string, if it exists, and return the result.
*
* e.g. "http://localhost:8000/api/v1/blah/" becomes "/api/v1/blah/"
* "/api/v1/blah/" stays "/api/v1/blah/"
*/
const baseUrlPattern = /^https?:\/\/[a-z\:0-9.]+/;
let result = "";
/**
* This Google Sheets script keeps data in the specified column sorted any time
* the data changes.
*
* After much research, there wasn't an easy way to automatically keep a column
* sorted in Google Sheets, and creating a second sheet to act as a "view" to
* my primary one in order to achieve that was not an option. Instead, I
* created a script that watches for when a cell is edited and triggers
* an auto sort.
*
// Reducer
export default function fetchDeliveryAddress(state = initialState, action){
switch(action.type){
case FETCH_DELIVERY_ADDRESS_LIST_SUCCESS:
return {
...state,
deliveryAddressList: action.deliveryAddressList,
deliveryDetailsState: action.deliveryDetailsState
}
export function getDeliveryAddress(some_state) {
return function(dispatch) {
axios(some_config_object)
.then(function(response) {
let deliveryDetailsState;
const deliveryAddressList = response.data.payload;
let updatedDeliveryAddressList = deliveryAddressList.map((item, index) => {
if(index !== 0) {