Skip to content

Instantly share code, notes, and snippets.

//A. Target Safari
if( $.browser.safari ) {};
//B. Target anything above IE6
if ($.browser.msie && $.browser.version > 6 ) {};
//C. Target IE6 and below
if ($.browser.msie && $.browser.version <= 6 ) {};
//D. Target Firefox 2 and above
@imsarvesh
imsarvesh / package.json
Created August 19, 2017 11:15
Github Angular2 prod deployment
"deploy" : "ng build --prod --base dist && git add -A && git commit -m 'dist pushed' && git subtree push --prefix dist origin gh-pages"
@imsarvesh
imsarvesh / CSS valid & invalid textbox validation.txt
Last active January 8, 2018 07:51
CSS valid & invalid textbox validation
input:not(:focus):valid {
border: 1px solid green;
}
input:not(:focus):valid + span::after {
content: '✓';
}
input:not(:focus):invalid {
border: 1px solid red;
}
input:not(:focus):invalid + span::after {
@imsarvesh
imsarvesh / gist:4f7d0ff02142b848c2cff14782f0cc42
Last active January 10, 2018 13:53
Start and Stop the Observable counter
import Rx from 'rxjs'
const Observable = Rx.Observable;
// App logic
const startButton = document.querySelector('#start');
const stopButton = document.querySelector('#stop');
const start$ = Observable.fromEvent(startButton, 'click');
const interval$ = Observable.interval(1000);
function email2csv(str){
str.split(';').map(e => e.substr(0,e.length-1).split('<').map(i=>i.trim()).join(',')).join('\n')
}
SELECT
CASE
WHEN u.first_name IS NULL AND u.last_name IS NULL THEN u.username
WHEN u.first_name = '' AND u.last_name = '' THEN u.username
ELSE u.first_name || ' ' || u.last_name
END as "name"
FROM users
h2 ~ p
article[class|="pillow"]
.soccer:not(h1)
td.student
section article > p a
li:only-child
h2:empty
div *
:root
.intro article::first-line
npx license mit > LICENSE && npx gitignore node && npx covgen me@imsarvesh.com && npm init -y
var isAnagrams = (str1,str2) => {
var charCount = new Map();
for(var c of str1.split('')){
charCount.set(c, (charCount.get(c) || 0) + 1);
}
for(var c of str2.split('')){
if(!charCount.has(c)) return false;
charCount.set(c, charCount.get(c) - 1);
}
var isAnyPermutationPalindrom = (str) => {
var charSet = new Set();
for(var c of str.split('')){
if(charSet.has(c)){
charSet.delete(c)
} else {
charSet.add(c)
}
}