{{ message }}

Instantly share code, notes, and snippets.

# cdarlint

• Beijing, China
Last active Jan 18, 2019
View product.java
 import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public class arraycalc { public static void main(String[] args) { List> n = new ArrayList(); n.add(Arrays.asList("A", "B", "C"));
Last active Sep 30, 2018
View combinations.java
 import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class arraycalc { public static void main(String[]args){ List arr = Arrays.asList(1,2,3,4,5); List c = Arrays.asList(4,5); List> result = arraycalc.combinations(arr,c,new ArrayList(),new ArrayList>());
Created Sep 29, 2018
list all cross product of list of list
View product.py
 def product(b): result=[] for i in b[0]: if len(b)>1: xx=product(b[1:]) result+=[[i]+v for v in xx] else: result+=[[i]] return result p=product([[1,2,3],[7,8],[9,4],[5,6]])
Created Sep 29, 2018
combination of list a, for each n in b, get \$C_a^n\$
View combinations.py
 import numpy as np def combinations(arr, c, cut=[], results=[]): if 0 in c: results+=[cut] if np.all(c<=0): return results for i in range(len(arr)):
Created Apr 27, 2017 — forked from John07/HLS_dvr.sh
A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.
View HLS_dvr.sh
 # required: ffmpeg (e.g. from homebrew), terminal-notifier from https://github.com/alloy/terminal-notifier # you can schedule this with launchd to run e.g. weekly # Specify in seconds how long the script should record (default here is 1 hour). seconds=3600 # Date format for the recording file name DATE=`date "+%d-%m-%y_%H-%M"` # start ffmpeg recording
Created Apr 27, 2017 — forked from refractalize/decrypt.rb
Decrypt HTTP Live Streaming TS files
View decrypt.rb
 def read_m3u8(m3u8) File.open(m3u8, 'r') do |file| keyfile = nil iv = 0 file.each_line do |line| line.chomp! if line =~ /^#EXT-X-KEY:METHOD=AES-128,URI="(.*?)"(,IV=0x(.*))?/ keyfile = \$1 if \$2 iv = \$3
Created Feb 21, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
 // Use Gists to store code you would like to remember later on console.log(window); // log the "window" object to the console
Created Jan 19, 2017