Skip to content

Instantly share code, notes, and snippets.

View amoilanen's full-sized avatar
💭
"Simplicity is prerequisite for reliability." Edsger W. Dijkstra

Anton Moilanen amoilanen

💭
"Simplicity is prerequisite for reliability." Edsger W. Dijkstra
View GitHub Profile
@amoilanen
amoilanen / remove_ubuntu_repos_from_apt.sh
Created October 21, 2016 17:38
Cleans up accidentally added ubuntu repos from the apt sources list in Debian
#Cleans up accidentally added Ubuntu repositories from the Debian's repository list
#!/bin/bash
sourcesDir=/etc/apt/sources.list.d
fileNames=$(ls $sourcesDir)
for fileName in $fileNames
do
fullFilePath=$sourcesDir/$fileName
fileSourcesList=$(cat $fullFilePath)
if [[ "$fileSourcesList" =~ "ubuntu" ]]
then
@amoilanen
amoilanen / mandelbrot.set.html
Last active October 13, 2016 20:42
Mandelbrot set visualization using the escape algorithm
<!-- Hosted https://output.jsbin.com/gowiruwiku/2 -->
<html>
<header>
<style type="text/css">
body {
margin: 0;
padding: 0;
background-color: black;
}
@amoilanen
amoilanen / howto_deb_repackage.txt
Created June 12, 2016 17:10 — forked from shamil/howto_deb_repackage.txt
Howto repackage deb packages
Use folowing steps to repackage dep package:
1: Extract deb package
# dpkg-deb -x <package.deb> <dir>
2: Extract control-information from a package
# dpkg-deb -e <package.deb> <dir/DEBIAN>
3. After completed to make changes to the package, repack the deb
# dpkg-deb -b <dir> <new-package.deb>
@amoilanen
amoilanen / blurayInstall.sh
Created June 12, 2016 16:48 — forked from sixman9/blurayInstall.sh
Install Bluray capability to Ubuntu/debian
#!/bin/bash
#Found at http://askubuntu.com/a/193065/35729
#don't forget to 'chmod +x <thisFile>'
sudo add-apt-repository ppa:motumedia/mplayer-daily
sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update
sudo apt-get upgrade
@amoilanen
amoilanen / webdriver.fetch.amazon.price.js
Created June 1, 2016 12:55
Demo of Webdriver API to fetch price and rating from Amazon.com
/*
* Demo of using Webdriver to automate browser testing.
* Fetches price and rating for a book from Amazon.com for a given book title.
*
* Example:
*
* node fetch.price.js SurviveJS
*/
var webdriver = require('selenium-webdriver'),
@amoilanen
amoilanen / combine.reducers.js
Created May 13, 2016 08:26
'combineReducers' from Redux re-implemented
/*
* Demonstrates how 'combineReducers' can be implemented.
*/
function combineReducers(reducers) {
return function(state, action) {
var reducerNames = Object.keys(reducers);
var combination = {};
reducerNames.forEach(function(reducerName) {
combination[reducerName] = reducers[reducerName](state[reducerName], action);
@amoilanen
amoilanen / rx.js.observable.interval.js
Last active April 22, 2016 22:02
Possible implementation of Rx.js `interval` function
Rx.Observable.interval = function(timeout) {
var DEFAULT_TIMEOUT_MS = 1000;
timeout = timeout || DEFAULT_TIMEOUT_MS;
return Rx.Observable.create(function(observer) {
var i = 0;
var interval = setInterval(function() {
observer.onNext(i++);
}, timeout);
});
@amoilanen
amoilanen / swap_variables_es6.js
Created March 23, 2016 11:47
Swapping variables using ES6 destructuring assignment
//JavaScript swapping variables
var x = 1, y = 2;
[x, y] = [y, x];
console.log("x = %s, y = %s", x, y);
@amoilanen
amoilanen / speech_apis_demo.js
Last active October 6, 2016 07:17
Demo of the JavaScript speech API, can be pasted and executed in the browser console in Google Chrome
//Based on the demo https://gist.github.com/wesbos/cd16b8b1815825f111a2
(function(host) {
if (typeof speechSynthesis === 'undefined') {
console.warn('No speech syntesis feature available,'
+ 'calls to "say" will be ignored, try latest Google Chrome');
host.say = function() {};
return;
}
@amoilanen
amoilanen / backup_github_account_repos.py
Last active June 14, 2017 22:27
Linux Python3 utility to make a snapshot of github repos for a given account and store them locally in a tar.gz archive
#!/usr/local/bin/python
# Linux utility for archiving Github.com repositories for a given account.
#
# Example usage:
#
# python archive_github_account.py antivanov ~/src/my-src
#
import sys