Skip to content

Instantly share code, notes, and snippets.

@hakimelek
hakimelek / sitemap.xml
Last active July 6, 2022 13:33
Priceline Demo Sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.priceline.com/</loc>
<lastmod>2022-07-06</lastmod>
</url>
<url>
<loc>https://www.priceline.com/hotels</loc>
<lastmod>2022-07-06</lastmod>
</url>
@hakimelek
hakimelek / priceline.com.har
Created February 26, 2019 22:47
HAR file for Priceline.com
This file has been truncated, but you can view the full file.
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
"startedDateTime": "2019-02-25T15:10:35.824Z",
@hakimelek
hakimelek / script.js
Created June 29, 2018 15:53
Detect Latest Image loaded on the page
const imagePath = '/path/to/image'
let latestImageTiming = 0
const p = window.performance.getEntriesByType('resource')
p.filter(e => { e.name.indexOf(imagePath) >= 0 && (latestImageTiming = Math.max(latestImageTiming, e.responseEnd))})
console.log(latestImageTiming)
Array(100)
.fill(0)
.map((a, i) => i+1)
.forEach(num => {
if (num % 3 === 0 && num % 5 === 0) return console.log('CracklePop')
else if (num % 3 === 0) return console.log('Crackle')
else if (num % 5 === 0) return console.log('Pop')
return console.log(num)
})
Verifying my Blockstack ID is secured with the address 1Mz5PM3Ag4H3V6kEo63zHLKpTx7piuVNk4 https://explorer.blockstack.org/address/1Mz5PM3Ag4H3V6kEo63zHLKpTx7piuVNk4
@hakimelek
hakimelek / webperf.js
Created August 22, 2017 20:18
Web performance object
/**
* Web performance object example:
*/
import 'performance-polyfill';
class WebPerfMetrics {
constructor() {
this.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
this.timing = (this.performance && this.performance.timing) ? this.performance.timing : null;
@hakimelek
hakimelek / router.jsx
Created July 19, 2017 03:33
SSR for Styled components in Vulcanjs change this file -> packages/vulcan-routing/lib/server/router.jsx
import React from 'react';
import { match, RouterContext, createMemoryHistory } from 'react-router';
import { renderToString } from 'react-dom/server'
import { ServerStyleSheet } from 'styled-components'
import moment from 'moment';
import { RoutePolicy } from 'meteor/routepolicy';
import { withRenderContextEnvironment, InjectData } from 'meteor/vulcan:lib';
@hakimelek
hakimelek / cache-control.js
Created June 8, 2017 20:09
Set cache control for assets except html
if (process.env.NODE_ENV === 'production') {
app.use('/drive/search/public', express.static(__dirname + '/../public'), {
maxAge: '1d',
setHeaders: setCustomCacheControl
});
} else {
app.use('/drive/search/public', express.static(__dirname + '/../client/src'));
}
export default class SimplePromise {
constructor () {
this.status = 'pending'; // 3 states pending, resolved, rejected
this.result = null; // initially set to null
this.callbacks = [];
}
then(onResolved, onRejected) {
if (this.status === 'resolved')
return this.resolve(onResolved, onRejected);
var customary = function (str) {
var freq = {};
var stringArray = str.split('');
for (let i=0; i<stringArray.length; i++) {
let char = stringArray[i];
if (freq.hasOwnProperty(char)) freq[char]++;
else {
freq[char] = 0;