Skip to content

Instantly share code, notes, and snippets.

@sharp
sharp / jquery-file-upload.js
Last active December 9, 2016 14:38
jquery file upload
$(function () {
$('#file-').fileupload({
dataType: 'json',
type: 'PATCH',
acceptFileTypes: /(\.|\/)(mp4)$/i,
minFileSize: 1000000,
url:"/micro/events/#{@event.id}/episodes/#{@episode.id}/upload",
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 90, 10);
import java.security.MessageDigest;
public class CheckSumBuilder {
// 计算并获取CheckSum
public static String getCheckSum(String appSecret, String nonce, String curTime) {
return encode("sha1", appSecret + nonce + curTime);
}
// 计算并获取md5值
public static String getMD5(String requestBody) {
# using libfaac on Mac OS X 10.6.8
# -vn : not copying video
# -acodec : specify codec used in flv file
# -ac : channels. 1 is for mono, 2 is for stereo
# -ab : specify bitrate for output file (note that rate is not kbps but bps)
# -ar : sampling frequency (Hz)
# -threads: number of threads for encoding
# "-strict experimental" is necessary to use libfaac
ffmpeg -y -i xxxxxxxxxxx.flv -vn -acodec aac -ac 2 -ab 128000 -ar 44100 -threads 4 -strict experimental xxxxx.m4a
@sharp
sharp / gist:3779509
Created September 25, 2012 01:46
create a romate mysql user
GRANT ALL PRIVILEGES ON *.* TO marty@'%' IDENTIFIED BY 'watch4keys' WITH GRANT OPTION;
console.log("Start", new Date().getTime());
var fs = require('fs');
for (var i = 1; i < 10; i++) {
fs.readFile("test.mp4",function(err, data) {
if(err)
console.log("read error: ", err);
else {
fs.writeFile(__dirname + "/new.mp4", data , function(err) {
if(err) {
console.log("write error: ", err);
@sharp
sharp / gist:775923
Created January 12, 2011 09:23
mongod run
If this is your first install, automatically load on login with:
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/1.6.3-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Or start it manually:
http://uthash.sourceforge.net/
http://www.monkey.org/~provos/libevent/
gem install addressable -v2.1.0
gem install merb-core -v1.0.12 --no-rdoc --no-ri
gem install merb-auth-core -v=1.0.12 --no-rdoc --no-ri
gem install merb-auth-more -v=1.0.12 --no-rdoc --no-ri
gem install merb-slices -v1.0.12 --no-rdoc --no-ri
`gem list|egrep ^merb`.split.select{|x|x !~ /[()]/}.each{|gem| system "gem uninstall #{gem}"}
`gem list|egrep ^dm-`.split.select{|x|x !~ /[()]/}.each{|gem| system "gem uninstall #{gem}"}