Skip to content

Instantly share code, notes, and snippets.

FROM debian:stable-slim
RUN apt update
RUN apt install -y \
curl git wget python3 \
zip unzip apt-transport-https \
ca-certificates gnupg clang \
cmake ninja-build pkg-config \
libgconf-2-4 gdb libstdc++6 \
libglu1-mesa fonts-droid-fallback \
@sr9yar
sr9yar / gist:46d07785eac774682c681acf1eeb1a47
Created February 20, 2021 12:17
Scroll to top animation with js
goToTop() {
const scrollToTop = window.setInterval(() => {
const pos = window.pageYOffset;
if (pos > 0) {
window.scrollTo(0, pos - 20);
} else {
window.clearInterval(scrollToTop);
}
@sr9yar
sr9yar / gist:45036c77d3a692eb33df4e9d99d42b23
Created January 8, 2021 16:09
Download a file by URL with JS
/**
* Version 1
*/
download(doc?: any): void {
const filename = 'https://via.placeholder.com/350x150';
const link = document.createElement('a');
link.style.display = 'none';
link.href = filename;
link.target = '_blank';
@sr9yar
sr9yar / gist:2af4630f0a9538e373fd8b28be89d836
Last active August 17, 2020 06:10
Detect Location Change
var oldHref = document.location.href;
window.onload = function() {
var bodyList = document.querySelector("body");
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (oldHref != document.location.href) {
oldHref = document.location.href;
console.log("LOCATION CHANGE:", oldHref);
.mb-0 {
margin-bottom: 0!important;
}
.mb-1 {
margin-bottom: .25rem!important;
}
.mb-2 {
margin-bottom: .5rem!important;
}
.mb-3 {
'use strict';
// Example Usage:
// const logger: any = require("./logger.js");
// const app = new Koa();
// app.use(logger());
const chalk = require('chalk');
const winston = require("winston");
@sr9yar
sr9yar / browser-window-resize-event-listener.js
Created June 9, 2019 12:38
Browser window resize event listener
function handleResize() {
const heights = {};
heights.window = window.innerHeight;
const [contactsTable] = document.getElementsByClassName('contacts-table');
if (contactsTable) {
@sr9yar
sr9yar / responsive-youtube-video.html
Created June 9, 2019 11:18
Responsive youtube video
<style>
.video-wrapper
{
position: relative;
padding-bottom: 51.5%;
padding-top: 25px;
height: 0;
border-radius: 4px;
overflow: hidden;
#!/bin/bash
# Saves the last frame of
# mp4/h264 matroska as png
# with ffmpeg
input_fn='output.mp4'
image_fn='output.png'
@sr9yar
sr9yar / setup-linux-pool.sh
Created December 4, 2018 17:19
Blender 2.79 install for Azure Render VM
#!/bin/bash
echo '# Running apt-get update ...'
apt-get update
echo '# Installing imagemagick ...'
apt-get install -y imagemagick
echo '# Installing blender ...'
apt-get install -y software-properties-common
add-apt-repository -y ppa:thomas-schiex/blender
apt-get install -y blender
echo '# Installing python-pip ...'