Skip to content

Instantly share code, notes, and snippets.

View 7kfpun's full-sized avatar
🦊

kf 7kfpun

🦊
View GitHub Profile
@7kfpun
7kfpun / order.css
Created January 28, 2019 10:45
Declaration order
.selector {
/* Positioning */
position: absolute;
z-index: 10;
top: 0;
right: 0;
bottom: 0;
left: 0;
/* Display & Box Model */
apt -y install python3-venv python-pip
@7kfpun
7kfpun / gist:6cf98a02a4d2b9813a1b7536a9a2a028
Created November 22, 2017 04:48
Chenimal - mysql-guideline
### Fundamental
- Use auto_increment integer as primary key for **all** tables(make its name be `id`)
- Comment is required for new columns& new tables
- Use `utf8` as the default charset for character type
- Single table size < 50 millions records
- Do not store images, files as binary type in database
- Do not connect **production** database through `ldev`, `dev`, `test` and `sandbox` environment
- Do not do **stress test** on production database
### Naming convention
@7kfpun
7kfpun / index.js
Created January 13, 2017 15:43
Fetch Hong Kong Air Quality Index (AQI)
const AQIURL = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.weather.org.hk%2Fenglish%2Faqi.html%22%20and%20xpath%3D%22%2F%2Ftable%2F%2Ftable%2F%2Ftable%22&format=json&diagnostics=true&callback=';
fetch(AQIURL)
.then(res => res.json())
.then((json) => {
// console.log(json.query.results)
console.log(json.query.results.table[0].tbody.tr.td.center.b.replace('Time: ', ''));
let result = {};
json.query.results.table[1].tbody.tr.slice(2).forEach((element) => {
result[element.td[0]] = {
NO2: element.td[1].font.content,
@7kfpun
7kfpun / gist:7b21a7d447344bb7a442547ff6ad167e
Created November 12, 2016 06:58
ffmpeg for App preview
# Resizing video to fit App preview requirement
ffmpeg -i input.mp4 -acodec copy -crf 12 -vf scale=1080:1920,setsar=1:1 output.mp4
# Double speed up
ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" -r 30 output.mkv
# Double speed up/slowing down audio:
ffmpeg -i input.mkv -filter:a "atempo=2.0" -vn output.mkv
ffmpeg -i video.mp4 -i audio.wav \
@7kfpun
7kfpun / gist:5450da9c11464ba32503dc370f747694
Created September 29, 2016 04:49
Android screenshot one line command
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "29x29",
@7kfpun
7kfpun / rss.js
Last active January 13, 2017 06:28
Convert RSS to JSON (Google Feed and Yahoo Feed)
// This API is officially deprecated and will stop working after December 15th, 2016.
// const RSS = (url) => {
// const GOOGLE_FEED_API_URL = `https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=-1&q=${encodeURIComponent(url)}`;
// return fetch(GOOGLE_FEED_API_URL).then(res => res.json()); // eslint-disable-line no-undef
// };
const RSS = (url) => {
const YAHOO_FEED_API_URL = `https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20feed%20where%20url%3D%27${encodeURIComponent(url)}%27&format=json&diagnostics=true&callback=`;
### Keybase proof
I hereby claim:
* I am 7kfpun on github.
* I am 7kfpun (https://keybase.io/7kfpun) on keybase.
* I have a public key ASCz-CUriFM3SHBl60Z2asfU2n4ayF8mVEGAp8uCE0TfJgo
To claim this, I am signing this object:
@7kfpun
7kfpun / gist:41d4fda1f9486cb79e9ca5f72ce05a5b
Created June 12, 2016 14:50
Round corners of an image with ImageMagick
convert -size 512x512 xc:none -draw "roundrectangle 0,0,512,512,40,40" png:- | convert src.png -matte - -compose DstIn -composite dst.png