Skip to content

Instantly share code, notes, and snippets.

View gonejack's full-sized avatar
💭
I may be slow to respond.

会有猫的 gonejack

💭
I may be slow to respond.
View GitHub Profile
<?php
/**
* Created by PhpStorm.
* User: Youi
* Date: 2015-12-05
* Time: 02:47
*/
// buffer all upcoming output
ob_start();
@gonejack
gonejack / ObjectCompareFunc.js
Last active February 25, 2016 08:30
recursive compare
function recursiveCompare(a, b) {
if (!(a instanceof Object) && !(b instanceof Object)) {
return a === b;
}
else if (a instanceof Array && b instanceof Array) {
for (var i = 0, l = a.length; i < l; i++) {
if (recursiveCompare(a[i], b[i]) === false) {
return false;
}
@gonejack
gonejack / appendQuery.js
Created March 14, 2016 02:26
append query parameters to URL
function (url, name, value) {
if (url) {
var parser = document.createElement('a');
parser.url = url;
return url + [(parser.search ? '&' : '?'), name, '=', value].join('');
}
else {
return '';
}
@gonejack
gonejack / isInFrame.js
Created March 14, 2016 03:41
check if current page is iframe
'isInFrame': function () {
try {
return window.self !== window.top;
}
catch (e) {
return true;
}
}
@gonejack
gonejack / zip.lib.php
Last active July 12, 2016 15:07
Create Zip Archive for download in memory(without using file system)
sometimes we don't want to make any usage to the hardisk, when we just want to grab something from remote server, and make a Zip archive for download, and the offical php ZipArchive module don't support this till now, so here is a class to make this(from phpMyAdmin library).
Here is sample usage:
require_once('zip.lib.php');
//create the zip
$zip = new zipfile();
//add files to the zip, passing file contents, not actual files
@gonejack
gonejack / image-url-to-data-uri.js
Created August 7, 2017 15:42 — forked from oliyh/image-url-to-data-uri.js
Convert an image url to a data URI without canvas
// hard won knowledge from http://stackoverflow.com/questions/20035615/using-raw-image-data-from-ajax-request-for-data-uri
var xmlHTTP = xhr.XMLHttpRequest();
xmlHTTP.open('GET', url, true);
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function(e) {
var arr = new Uint8Array(this.response);
var raw = String.fromCharCode.apply(null,arr);
var b64 = base64.encode(raw);
var dataURL="data:image/png;base64," + b64;
};
@gonejack
gonejack / img-to-dataurl.js
Last active August 7, 2017 15:52
JS :: convert image to data url with javascript
console.clear();
var img = new Image();
img.src = 'img/img.png';
img.onload = function () {
var canvas = document.createElement('canvas'), context = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
context.drawImage(img, 0, 0, img.width, img.height);
console.log(canvas.toDataURL('image/png'));
public class MainClass {
public static void main(String[] args){
ClassLoader classLoader = MainClass.class.getClassLoader();
try {
Class aClass = classLoader.loadClass("com.jenkov.MyClass");
System.out.println("aClass.getName() = " + aClass.getName());
} catch (ClassNotFoundException e) {
Install Homebrew OS X package manager:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install ffmpeg with x265 support:
brew install ffmpeg --with-fdk-aac --with-sdl2 --with-freetype --with-libass --with-libvorbis --with-libvpx --with-opus --with-x265
Convert video to x265:
ffmpeg -i input -c:v libx265 -preset medium -crf 28 -c:a aac -b:a 128k output.mp4
Uninstall ffmpeg:
@gonejack
gonejack / ffmpeg.md
Created December 17, 2017 06:23 — forked from v5tech/ffmpeg.md
ffmpeg视频合并、格式转换、截图

使用ffmpeg合并MP4文件

ffmpeg -i "Apache Sqoop Tutorial Part 1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i "Apache Sqoop Tutorial Part 2.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "Apache Sqoop Tutorial Part 3.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate3.ts
ffmpeg -i "Apache Sqoop Tutorial Part 4.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate4.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|intermediate3.ts|intermediate4.ts" -c copy -bsf:a aac_adtstoasc "Apache Sqoop Tutorial.mp4"