Skip to content

Instantly share code, notes, and snippets.

@vmeli
vmeli / links.md
Created August 19, 2024 21:28 — forked from igrigorik/links.md
HAR Show links & resources
@vmeli
vmeli / rAF.js
Created June 11, 2024 14:29 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@vmeli
vmeli / sites
Created May 28, 2024 19:48 — forked from tyingq/sites
newscatcher
01net.com
057.ua
0629.com.ua
10best.com
112.ua
161.ru
163.com
180.com.uy
1limburg.nl
20minutes.fr
@vmeli
vmeli / Rss.ts
Created May 28, 2024 17:21 — forked from fredrikbergqvist/Rss.ts
How to create an RSS feed for next.js
import React from "react";
import { NextPageContext } from "next";
const blogPostsRssXml = (blogPosts: IBlogPost[]) => {
let latestPostDate: string = "";
let rssItemsXml = "";
blogPosts.forEach(post => {
const postDate = Date.parse(post.createdAt);
if (!latestPostDate || postDate > Date.parse(latestPostDate)) {
latestPostDate = post.createdAt;
@vmeli
vmeli / index.html
Created August 4, 2023 21:14 — forked from billdwhite/index.html
d3 Virtual Scrolling Plugin
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Virtual Scrolling Demo</title>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
@vmeli
vmeli / integration.html
Created May 12, 2023 00:52 — forked from rafaelverger/integration.html
Integrate DFP click macro and cache buster to Space AdManager
<script type="text/javascript">
var space = window.space || { runs: [] };
var ADID = 'YOUR_AD_ID'; var WIDTH = 1; var HEIGHT = 1;
space.runs.push(function () {
space
.ad(ADID)
.setSize(WIDTH, HEIGHT)
.setMacro('%%CLICK_URL_UNESC%%')
.setCacheBuster('%%CACHEBUSTER%%')
.fire();
<!-- PREBID & AMAZON AUCTION IN PARALLEL -->
<script>
var AUCTION_TIMEOUT = 1500;
var FAILSAFE_TIMEOUT = 3000;
var requestManager = {
adserverRequestSent: false,
aps: false,
prebid: false,
};
@vmeli
vmeli / next-hoc.js
Created January 11, 2021 02:46 — forked from dstreet/next-hoc.js
Example HOC with Next.js
import React from 'react'
/*
* Higher order component that passes `getInitialProps` through
* to the child component
*/
const HOC = function(Child) {
return class Higher extends React.Component {
static getInitialProps(ctx) {
return Child.getInitialProps(ctx)
@vmeli
vmeli / nextjs-hoc-authorization.js
Created January 11, 2021 02:45 — forked from whoisryosuke/nextjs-hoc-authorization.js
ReactJS - NextJS - A HOC for wrapping NextJS pages in an authentication check. Checks for getInitialProps on the child component and runs it, so you still get SSR from the page. Also includes a user agent for Material UI.
import React, {Component} from 'react'
import Router from 'next/router'
import AuthService from './AuthService'
export default function withAuth(AuthComponent) {
const Auth = new AuthService('http://localhost')
return class Authenticated extends Component {
static async getInitialProps(ctx) {
// Ensures material-ui renders the correct css prefixes server-side
@vmeli
vmeli / twitter.js
Created March 12, 2020 18:59
Only load twitter widgets if availbale
// Lovely little snippet from: http://www.blackfishweb.com/blog/asynchronously-loading-twitter-google-facebook-and-linkedin-buttons-and-widgets-ajax-bonus
twttr.widgets.load();
// So to be sure we do not load the script more than once we can check if the twittr object exists and only if it doesn’t load the script, and if it’s already there we can just have the script load the widgets:
$(window).load(function () {
loadTwitter();
});
function loadTwitter() {