Skip to content

Instantly share code, notes, and snippets.

Avatar
💪
I may be slow to respond.

夏永锋 youngsterxyf

💪
I may be slow to respond.
View GitHub Profile
@youngsterxyf
youngsterxyf / ffmpeg.md
Created Aug 19, 2017 — forked from ameizi/ffmpeg.md
ffmpeg视频合并、格式转换、截图
View ffmpeg.md

使用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"
View ip_class.php
<?php
function checkIPClass($ip) {
$ipLong = ip2long($ip);
if ($ipLong == -1 || $ipLong === FALSE) {
return null;
}
$ipBinaryString = sprintf('%b', $ipLong);
$ipBinaryString = str_pad($ipBinaryString, 32, '0', STR_PAD_LEFT);
View awk-sort-uniq.sh
cat words.txt | sort | uniq -c | sort -k1,1nr | head -10
/*
sort: 对单词进行排序
uniq -c: 显示唯一的行,并在每行行首加上本行在文件中出现的次数
sort -k1,1nr: 按照第一个字段,数值排序,且为逆序
head -10: 取前10行数据
*/
cat filter.log | awk -F '[' '{print $4}' | awk -F ':' '{print $1}' | sort | uniq -c | sort -k1,1nr | head -10
View wget_rss.sh
#!/bin/sh
for host in drops.wooyun.org www.aqniu.com www.freebuf.com
do
/usr/bin/wget http://$host/feed -O /home/work/feeds/$host/feed_$(date "+%Y-%m-%d-%H_%M_%S").xml >> /home/work/feeds/$host/wget.log 2>&1
done
View jsonToMap.java
private HashMap<String, Object> jsonToMap(String t) throws JSONException {
HashMap<String, Object> map = new HashMap<String, Object>();
JSONObject jObj = new JSONObject(t);
Iterator<?> keys = jObj.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
map.put(key, jObj.get(key));
}
return map;
}
View rmNotFirstNegative.scala
object Test extends App {
val a = Array(10, 9, -1, 8, -2, -100, 1000).toBuffer
var first = true
val indexes = for (i <- 0 until a.length if first || a(i) >= 0) yield {
if (a(i) < 0)
first = false
i
}
for(j <- 0 until indexes.length)
a(j) = a(indexes(j))
@youngsterxyf
youngsterxyf / lonlat.js
Created May 10, 2015
经纬度距离计算
View lonlat.js
var appFunc = {
getDistance: function (firstLon, firstLat, secondLon, secondLat) {
var radFirstLon = appFunc.rad(firstLon);
var radFirstLat = appFunc.rad(firstLat);
var radSecondLon = appFunc.rad(secondLon);
var radSecondLat = appFunc.rad(secondLat);
var latDiff = radFirstLat - radSecondLat;
var lonDiff = radFirstLon - radSecondLon;
View deepCopy.js
function deepCopy(p, c) {
c = c || {};
for (var i in p) {
if (p.hasOwnProperty(i)) {
if (typeof p[i] === 'object') {
c[i] = Array.isArray(p[i]) ? [] : {};
deepCopy(p[i], c[i]);
} else {
c[i] = p[i];
}
@youngsterxyf
youngsterxyf / extendCopy.js
Created Apr 30, 2015
对象之间的继承
View extendCopy.js
function extendCopy(p) {
var c = {};
for (var i in p) {
c[i] = p[i];
}
c.uber = p;
return c;
}
@youngsterxyf
youngsterxyf / extend_by_copy.js
Created Apr 30, 2015
简单地通过将父对象的属性拷贝给子对象来构建继承
View extend_by_copy.js
function extend(Child, Parent) {
var p = Parent.prototype;
var c = Child.prototype;
for (var i in p) {
c[i] = p[i];
}
c.uber = p;
}
You can’t perform that action at this time.