Skip to content

Instantly share code, notes, and snippets.

View aravindbaskaran's full-sized avatar

Aravind aravindbaskaran

View GitHub Profile
;; Fire up a REPL and try it out
(let [list [1 2 3]
[x y z] list]
(println x y z))
;; Better one
(let [[x y z a :as list] [1 2 3]]
(println x y z a list))
@aravindbaskaran
aravindbaskaran / ring-ip-whitelist.clj
Last active October 22, 2016 21:01
Middleware to secure API groups to set of whitelist IPs
(ns sw.ring-ip-whitelist
"Just for reference, to show the :require for this to work"
(:require [clojure.string :as str]))
(defn- header-value
[request k]
(-> request :headers (get k)))
(defn- get-host-addr [request]
(or (header-value request "x-forwarded-for")
(:remote-addr request)
@aravindbaskaran
aravindbaskaran / custom-wishlist-page.js
Last active April 6, 2021 12:22
Swym Wishlist Plus - Custom Wishlist UX for your site - An example using the Supply theme
(function(){
var _products = {};
if(!window.SwymCallbacks){window.SwymCallbacks = [];}
window.SwymCallbacks.push(function(){
_swat.fetchWrtEventType(function(products){
// render products - array of objects with same structure as productData
// {{Insert your rendering function}}
renderProducts(products);
// products count - products.length
// {{Insert your count update}}
@aravindbaskaran
aravindbaskaran / layout.scss
Created March 16, 2020 11:05
Media query free layout options
//Option 1 - With flex
.Product-wrapper {
display: flex;
justify-content: space-around;
max-width: min(80%, 1080px);
.Product {
margin-bottom: 30px;
flex: 1 1 280px;
}
}