Skip to content

Instantly share code, notes, and snippets.

@synzhang
synzhang / hls.sh
Created November 12, 2024 03:05 — forked from stenuto/hls.sh
HLS ffmpeg script
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]"
exit 1
}
# Check if at least one argument (input file) is provided
if [ $# -lt 1 ]; then
class Component {
static utils = {
log() {
}
}
static DEFAULTS = {
}
static Extension = {
@synzhang
synzhang / oloo.js
Last active December 9, 2016 10:09
OLOO(Objects linked to other objects) style delegation
/**
* @desc OLOO(Objects linked to other objects) style delegation
* @see 《You Don't Know JS》 Chapter 6
*/
const Widget = {
width: 50,
height: 50,
@synzhang
synzhang / eventtarget.js
Created September 23, 2014 05:45
EventTarget
/**
* @desc EventTarget
* @see 《JavaScript高级程序设计(第3版)》 p616
*/
function EventTarget(){
this.handlers = {};
}
EventTarget.prototype = {
@synzhang
synzhang / module-loader.js
Created February 18, 2014 14:17
简易 JavaScript 模块加载器
/**
* @desc Module Loader
* @see http://leechan.me/?p=1241
*/
;(function(global){
var mapping = {}, cached = {};
global.define = function(id, func){
mapping[id] = func;
};
@synzhang
synzhang / requestAnimationFrame.js
Created January 6, 2014 01:52
requestAnimationFrame ployfill
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelRequestAnimationFrame = window[vendors[x]+
'CancelRequestAnimationFrame'];
}
@synzhang
synzhang / target-browser.css
Created October 27, 2013 13:58
CSS 判断浏览器
/**
* @desc CSS 判断浏览器
*/
/* Target IE 10 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
p {
color: red;
}
}
@synzhang
synzhang / 1.comment.html
Last active December 25, 2015 09:59
注释风格
<header>
</header> <!-- / header -->
<div id="wrapper">
</div> <!-- / #wrapper -->
<div class="module">
</div> <!-- / .module -->
@synzhang
synzhang / media-queries-breakpoints.css
Last active December 25, 2015 05:59
Media Queries Breakpoints
/**
* @desc Media Queries Breakpoints
* @see http://getbootstrap.com/css/#grid
*/
/* Extra small devices (phones, up to 480px) */
/* No media query since this is the default. */
/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) { ... }
@synzhang
synzhang / js-lazy-loading.html
Created October 10, 2013 05:59
Javascript Lazy Loading
<script id="lazy">
// Make sure you strip out (or replace) comment blocks in your JavaScript first.
/* JavaScript of lazy module */
</script>
<script>
function lazyLoad() {
var lazyElement = document.getElementById('lazy');
var lazyElementBody = lazyElement.innerHTML;
var jsCode = stripOutCommentBlock(lazyElementBody);
eval(jsCode);