Skip to content

Instantly share code, notes, and snippets.

# tested on Debian
# require ffmpeg@2.6.3 with --enable-libfreetype for drawtext extension
# ffmpeg streaming to ffserver feed
# file -> ffmpeg (playback) -> ffmpeg (add timestamp) -> ffmpeg (add timestamp) -> ffserver (FFM delivery)
ffmpeg -i your-file.mp4 -tune zerolatency -filter:v "setpts=1.0*PTS" -f nut pipe:1 \
| ffmpeg -re -i pipe:0 -vf "drawtext=expansion=normal:fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf:reload=1:textfile=test.txt: x=50: y=50: fontcolor=white" -tune zerolatency -f nut pipe:1 \
| ffmpeg -y -i pipe:0 -tune zerolatency http://ffserver-ip:7000/feed1.ffm
@manishsat
manishsat / BalancedPartition.java
Created May 19, 2016 19:55 — forked from pyemma/BalancedPartition.java
Classical Balanced Partition Problem
// Balanced Partition problem, the target is to partition the array into two
// sets so that the difference of the two sets' sum is as small as possible
// use dp to find the possible sets sum as close to S/2 as possbile, where S
// is the sum of all elements. DP[i][j] means whether we can build sum j using
// elements from 0 to i, DP[i][j] = DP[i-1][j] | DP[i-1][j-A[i]]
public class BalancedPartition {
public static int balancedPartition(int[] A) {
int sum = 0;
int n = A.length;
@manishsat
manishsat / interviewitems.MD
Created October 13, 2016 21:17 — forked from amaxwell01/interviewitems.MD
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
@manishsat
manishsat / WordLadderII.java
Created December 9, 2016 06:51 — forked from bittib/WordLadderII.java
Word Ladder II @leetcode
/**
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:
Only one letter can be changed at a time
Each intermediate word must exist in the dictionary
For example,
Given:
start = "hit"
end = "cog"
@manishsat
manishsat / ZigZagConvertion.java
Created December 9, 2016 06:52 — forked from bittib/ZigZagConvertion.java
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string conver…
/*
* Time complexity : O(n), Space Complexity : O(n),
* We could just use a n size char array instead of using nRows' StringBuilder array. See the convert0 for the detail
*/
public static String convert(String s, int nRows){
if (s == null || s.length() <= 1 || nRows <= 1)
return s;
StringBuilder[] sbs = new StringBuilder[nRows];
for (int i=0; i<nRows; i++){
@manishsat
manishsat / SmallestMultiple.java
Created December 9, 2016 06:52 — forked from bittib/SmallestMultiple.java
Project Euler Problem 5 本题求的是小于某个数的所有数集合的LCM,比较快的做法参考维基百科 利用整数的唯一分解定理,还可以用质因子分解法。将每个整数进行质因数分解。对每个质数,在质因数分解的表达式中寻找次数最高的乘幂,最后将所有这些质数乘幂相乘就可以得到最小公倍数。
public static int solve(int N){
int[] primes = new int[N];
int cnt = 0;
boolean[] isp = new boolean[N+1];
Arrays.fill(isp, true);
isp[0] = false;
isp[1] = false;
for (int i=2; i<=N; i++){
if (isp[i]){
@manishsat
manishsat / Subsets.java
Created December 9, 2016 06:53 — forked from bittib/Subsets.java
Subsets
/*
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.
The solution set must not contain duplicate subsets.
For example,
If S = [1,2,3], a solution is:
@manishsat
manishsat / WordLadderII.java
Created December 9, 2016 06:54 — forked from bittib/WordLadderII.java
WordLadder II
/*
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:
•Only one letter can be changed at a time
•Each intermediate word must exist in the dictionary
For example,
Given:
start = "hit"
end = "cog"
@manishsat
manishsat / MorrisInOrderTraverse.java
Created December 9, 2016 06:54 — forked from bittib/MorrisInOrderTraverse.java
Morris InOrder Traverse Algorithm
public static void morrisInOrderTraverse(TreeNode root){
TreeNode ptr = root;
while (ptr != null){
if (ptr.left == null){
visit(ptr);
ptr = ptr.right;
}else{
TreeNode node = ptr.left;
while (node.right != null && node.right != ptr)
node = node.right;
@manishsat
manishsat / FlattenBinaryTreeToLinkedList.java
Created December 9, 2016 07:01 — forked from bittib/FlattenBinaryTreeToLinkedList.java
Flatten Binary Tree to Linked List
/*
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ \
2 5
/ \ \