Skip to content

Instantly share code, notes, and snippets.

@sz-alpar
sz-alpar / programmers-oath.kt
Created June 11, 2017 07:25
Programmer's Oath by Robert C. Martin
/**
* Programmer's Oath by Robert C. Martin
* http://blog.cleancoder.com/uncle-bob/2015/11/18/TheProgrammersOath.html
*/
val PREAMBLE = """
In order to defend and preserve the honor of the profession of computer programmers,
I Promise that, to the best of my ability and judgement:
"""
#!/bin/bash
echo "$1" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"'
#!/bin/bash
#
# Send adb commands to all connected devices.
#
# Usage: adb-all COMMANDS
#
adb devices | tail -n +2 | cut -sf 1 | xargs -I {} adb -s {} $@
@sz-alpar
sz-alpar / print.css
Created December 23, 2016 13:45
nosalty.hu disable images and recommendations for printing
* {
background-color: transparent;
}
.print-only {
display: none;
}
@media print {
html,body {
@sz-alpar
sz-alpar / ffmpeg_two_pass.sh
Last active March 30, 2016 08:28
ffmpeg two pass compression
ffmpeg -y -i input.mov -c:v h264 -preset medium -b:v 1800k -pass 1 -c:a libvo_aacenc -b:a 128k -f mp4 /dev/null && \
ffmpeg -i input.mov -c:v h264 -preset medium -b:v 1800k -pass 2 -c:a libvo_aacenc -b:a 128k output.mp4
@sz-alpar
sz-alpar / angular_app.js
Created March 31, 2014 12:54
AngularJS watch array length change.
angular.module('myApp', []);
angular.module('myApp').controller('watcherCtrl', ['$scope', function($scope) {
$scope.myArray = [];
var index = 42;
$scope.push = function () {
$scope.myArray.push(index++);
}
@sz-alpar
sz-alpar / amazon_srt_player.js
Created March 16, 2014 14:34
Amazon srt player.
// Created by: Szotyori Alpar
// Spent time: 15.03.2014 - 5 hrs
// Spent time: 16.03.2014 - 3 hrs
var DEBUG = true;
// JS loader function from: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
function loadjscssfile(filename){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
@sz-alpar
sz-alpar / this.js
Created February 20, 2014 11:10
'this' in a method invocation and testing when a function is added to the object.
// You need log4javascript for the logging to work
// Or use the console, if log4javascript is not available
if (typeof log !== 'Object') {
log = {
debug: function (message) {
console.log(message);
}
}
}
@sz-alpar
sz-alpar / splice.js
Created February 20, 2014 11:07
Splice.
Array.prototype.deleteFromIndex = function(index) {
return this.splice(index,array.length-index);
}
var array = ["Apple","Turtle","Microsoft","Atari","John","Carter","HTC"];
var array2 = array.deleteFromIndex(2);
console.log(array);
console.log(array2);
@sz-alpar
sz-alpar / minmax.js
Created February 20, 2014 11:04
Constrict a value to an interval. If the value exceeds one of the boundaries, the result will hold the exceeded boundary.
var value = -50;
var max = 0;
var min = -30;
var result = value;
if (result >= max) {
result = max;
} else if (result < min) {
result = min;
}
console.log('result with ifs: ' + result);