Skip to content

Instantly share code, notes, and snippets.

@chauek
chauek / convert_all_movies_progress.sh
Created June 7, 2019 11:31
Converts movies in current and sub dirs showing progressbar.
#!/bin/bash
# Install ffmpeg on OSX:
# brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libvorbis --with-libvpx --with-opus --with-x265
IFS=$'\n'
WATCHER_PORT=9998
LINE=""
PERCENT=0
@chauek
chauek / convert_all_movies.sh
Created March 11, 2018 07:11
Bash script to re-encode all movies in current and sub directories to x265.
#!/bin/bash
# Install ffmpeg on OSX
# brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libvorbis --with-libvpx --with-opus --with-x265
IFS=$'\n'
FILES=$(find . -iname "*.mp4" -o -iname "*.avi" -o -iname "*.MPG" -o -iname "*.MTS" -o -iname "*.mkv" | grep -v -E "_x26[4-5].mp4" | grep -v -E "_x26[4-5].avi")
AMOUNT=$(echo "$FILES" | sed '/^\s*$/d' | wc -l)
AMOUNT="$(echo -e "${AMOUNT}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
function saveAs(uri, filename) {
var link = document.createElement('a');
if (typeof link.download === 'string') {
link.href = uri;
link.download = filename;
//Firefox requires the link to be in the body
document.body.appendChild(link);
//simulate click
// 1. Write a code snippet that sets a to an array of n random integers between 0
// (inclusive) and n (exclusive).
var a = new Array[Int](10) //> a : Array[Int] = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
for(i <- 0 until a.length) a(i) = scala.util.Random.nextInt(10)
a //> res0: Array[Int] = Array(9, 0, 5, 8, 6, 6, 3, 9, 0, 3)
// 2. Write a loop that swaps adjacent elements of an array of integers. For example,
// Array(1, 2, 3, 4, 5) becomes Array(2, 1, 4, 3, 5).
a = Array[Int](1,2,3,4,5)
a //> res1: Array[Int] = Array(1, 2, 3, 4, 5)
@chauek
chauek / weeb.tv.js
Last active August 29, 2015 14:08
Skrypt poprawia wyświetlanie widoku programu na weeb.tv
// ==UserScript==
// @name Panel weeb.tv
// @namespace weeb.tv
// @version 0.1
// @description Skrypt poprawia wyświetlanie widoku programu na weeb.tv
// @author Chauek
// @match http://weeb.tv/online/*
// @match http://weeb.tv/channel/*
// @grant none
// ==/UserScript==
@chauek
chauek / robot.js
Created December 4, 2012 13:58
tescik
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.rotateCannon(360);
@chauek
chauek / php_synopsis.php
Created January 3, 2012 10:07
Example of MailZ API
<?php
/**
*
* Implementation of sample scenario using MailZ API:
*
* Send message
* Show message status
*
* @author Pawel Chalkowski