Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Daiz
Daiz / 4chan.html
Last active August 29, 2015 14:02
Simple 4chan thread JSON renderer in ES6 (no mobile data)
<html>
<head>
<title>Test</title>
<body>
<div class="thread">
</div>
<script src="https://traceur-compiler.googlecode.com/git/bin/traceur.js"></script>
<script src="https://traceur-compiler.googlecode.com/git/src/bootstrap.js"></script>
<script src="data2.js"></script>
<script type="module">
function g(a,b,c) {
c = !!+this;
if(!a && !b && !c) return g.bind(1,'go');
if( a && !b && !c) return 'g' + a;
if( a && !b && c) return g.bind(1,a + 'o');
if( a && b && c) return a + b;
}
function g(a,b) {
if(!+this) return a ? 'g' + a : g.bind(1,'go');

Encoding settings for the first comparison set

Beamr Video

videomini ver. 90.15 options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00

x264 Closely Matched Settings

x264 --bframes 0 --me umh --subme 8 --chroma-qp-offset 0 --ipratio 1.41 --qpmin 10 --qpmax 51 --crf 18.35

@Daiz
Daiz / vagrant.log
Created April 12, 2013 22:07
Vagrant debug log for hashicorp/vagrant#1580
INFO global: Vagrant version: 1.1.5
DEBUG global: Loading core plugin: C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/commands/box/plugin.rb
INFO manager: Registered plugin: box command
DEBUG global: Loading core plugin: C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/commands/destroy/plugin.rb
INFO manager: Registered plugin: destroy command
DEBUG global: Loading core plugin: C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/commands/halt/plugin.rb
INFO manager: Registered plugin: halt command
DEBUG global: Loading core plugin: C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/commands/init/plugin.rb
INFO manager: Registered plugin: init command
DEBUG global: Loading core plugin: C:/vagrant/vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/commands/package/plugin.rb
for(var i = 0, startFrame = 0, endFrame = 0; i < s; i++) {
startFrame = ((framecount/parts)*i|0);
endFrame = ((framecount/parts)*(i+1)|0) - 1;
trimPoints = trimPoints.concat([startFrame,endFrame]);
console.log(endFrame - startFrame + 1);
}
// sb - startBytes
// eb - endBytes
// parts - number of parts
@Daiz
Daiz / fairandsquare.js
Created April 22, 2013 09:27
I ran into the "Fair and Square" problem of Google's 2013 Code Jam ( https://code.google.com/codejam/contest/2270488/dashboard#s=p2&a=2 ) last night and ended up spending some time solving the large input 1 case in JS. Here's what I came up with (run it in node). It solves the 10^14 range in less than a millisecond on my end. Doesn't really work…
var fs = require('fs');
var lines = fs.readFileSync('./C-large-practice-1.in', 'utf8').replace(/\r\n|\r/g,'\n').split('\n');
var time = Date.now();
var arr = palindromes(Math.pow(10,14));
time = Date.now() - time;
console.time("Total time for case solving");
for(var i = 0, ii = lines.shift(); i < ii; i++) {
@Daiz
Daiz / lua-slakefile.ls
Created May 9, 2013 14:21
Slakefile for a Lua project.
require 'shelljs/global'
require! {
'gaze'
'charm'
}
charm = charm!
charm.pipe process.stdout
task 'build', 'Compile *.moon files to lib/*.lua', !->
require! \Q
# if you're not using prelude-ls
each = (fn, array) ->
[fn i for i in array]
random-msec = ->
Math.ceil Math.random! * 1000
delay = (n, v) ->
interface MatterConfig {
foo: boolean;
}
interface Example {
foo: string;
bar: number;
}
type CombinedConfig = Example & MatterConfig;

Don't Buy the Snake Oil of Beamr Video

You might have heard of Beamr Video, and their impressive claims about reducing video bitrates by "up to 4x, without losing quality". Sounds too good to be true? Well, as a matter of fact, it is.

The Example Videos

The four example videos that Beamr has on their site use very high bitrates - 40-50 Mbps for 1080p video. These are the kind of bitrates you find on Blu-ray discs, whereas with something like Netflix's "SuperHD" you'd only get around ~5.6 Mbps (5800 kbps) 1080p video, and with 720p Netflix video the bitrate is only around ~3.5 Mbps (3600 kbps). If you have watched online streams like these, you'll probably know that they look quite decent. Now, if you look at the Beamr Video examples, you'll notice that even for their "reduced" clips, the bitrates are still around 9 Mbps minimum, and average as high as ~30 Mbps.

At this point, you can probably see the trick that Beamr is trying to pull