Skip to content

Instantly share code, notes, and snippets.

View vahidd's full-sized avatar
🎯
Focusing

Vahid Mohammadi vahidd

🎯
Focusing
View GitHub Profile
@vahidd
vahidd / rerender-on-resize-hoc.js
Created August 20, 2018 06:36
This HOC renders the inner component on page resize. (Note that this hoc requires lodash in your project)
import React from 'react';
import debounce from 'lodash/debounce';
/**
* Usage example:
* export default rerenderOnResize()(Header);
*/
export default () => (WrappedComponent) => {
class ReRenderOnResize extends React.PureComponent {
componentDidMount() {
@vahidd
vahidd / Image.jsx
Last active December 21, 2017 11:36
Simple image react component which allows you to have preloader for image and fade-in image on load
import React from 'react';
import PropTypes from 'prop-types';
export default class Image extends React.Component {
constructor () {
super();
this.state = {
loaded: false
};
@vahidd
vahidd / download_hls_stream.txt
Last active February 19, 2024 22:46
How to download HLS streams
Take the following steps:
1- First install ffmpeg with brew:
$ brew install ffmpeg
2- Then run the following command:
$ ffmpeg -i "HLS STREAM URL" -c copy -bsf:a aac_adtstoasc output.mp4
(don't forgot to replace "HLS STREAM URL" with your stream URL and also double quote the url)
@vahidd
vahidd / functions.php
Last active October 5, 2016 20:10
WordPress dynamic file version based on file content
<?php
add_action( 'wp_enqueue_scripts', function () {
$fileURI = trailingslashit( get_template_directory_uri() ) . 'styles.css';
$filePath = trailingslashit( get_template_directory() ) . 'styles.css';
// Or wp_enqueue_style
wp_enqueue_script(
'some-script',
$fileURI,