Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
JacobHsu / promise1
Created June 20, 2020 01:49
promise1
const promise = new Promise((resolve, reject) => {
console.log(1);
resolve();
console.log(2);
reject('error');
})
promise.then(() => {
console.log(3);
}).catch(e => console.log(e))
console.log(4);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
</head>
<body>
<div class="card" style="width: 20rem;">
@JacobHsu
JacobHsu / dabblet.css
Created May 11, 2017 05:20 — forked from csssecrets/dabblet.css
Flexible background positioning
/**
* Flexible background positioning
* via extended background-position
*/
div {
background: url(http://csssecrets.io/images/code-pirate.svg)
no-repeat bottom right #58a;
background-position: right 20px bottom 10px;
@JacobHsu
JacobHsu / index.html
Last active March 16, 2017 01:37
jQuery .on // source https://jsbin.com/dovuquk
<style id="jsbin-css">
/* line 5, ../../app/assets/stylesheets/partials/_reset.css.sass */
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cite, code, em, img, strong, sub, sup, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, nav, output, section, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
@JacobHsu
JacobHsu / index.html
Last active February 9, 2017 05:37 — forked from anonymous/index.html
ES6 toUpperCase JS Bin// source https://jsbin.com/tesoqay
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<button id="main_button">click me</buttton>
<script id="jsbin-javascript">
@JacobHsu
JacobHsu / hello-world-react.markdown
Created October 17, 2016 02:14
Hello World React
@JacobHsu
JacobHsu / index.html
Created October 14, 2016 01:29
Random Quote Machine
<div class="quote-box">
<div class="quote-text">
<i class="fa fa-quote-left"> </i><span id="text"></span>
</div>
<div class="quote-author">
- <span id="author"></span>
</div>
<div class="buttons">
<a class="button" id="tweet-quote" title="Tweet this quote!" target="_blank">
/**
* @param {number} n
* @return {boolean}
*/
var isPowerOfThree = function(n) {
return n.toString(3).replace(/0/g, '') === '1';
};
/*
Given an integer, write a function to determine if it is a power of three.
@JacobHsu
JacobHsu / get_app_info.php
Created April 13, 2016 05:49
#app #store #php
<?php
$url = 'https://www.microsoft.com/zh-tw/store/apps/facebook/9wzdncrfhv5g';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
@JacobHsu
JacobHsu / ffmpeg.php
Created April 13, 2016 05:39
#ffmpeg #PHP
<?php
$ffmpeg_location ='"C:\Program Files\ffmpeg-20140928-git-3edb9aa-win64-static\bin\ffmpeg.exe"';
$file_path = 'C:\\ed2b6a653ded.mp4';
$src_cover = 'C:\src_cover.jpg';
$ffm = $ffmpeg_location . ' -i '. $file_path . ' -ss 00:00:01 -f image2 -vframes 1 ' . $src_cover.' 2>&1';
$xyz = shell_exec($ffm);
$search='/Duration: (.*?),/';
preg_match($search, $xyz, $matches);
$duration = explode(':', $matches[1]);