Skip to content

Instantly share code, notes, and snippets.

View apkostka's full-sized avatar

Andrew Kostka apkostka

View GitHub Profile
#!/bin/sh
player_status=$(playerctl status 2> /dev/null)
if [ "$player_status" = "Playing" ]; then
echo "$(playerctl metadata artist) - $(playerctl metadata title)"
elif [ "$player_status" = "Paused" ]; then
echo "Paused - $(playerctl metadata artist) - $(playerctl metadata title)"
else
echo "#3"
# General format of my i3 configuration file
# Uses colors from .Xresources to color windowborders
# Now it uses polybar for configuration.
# i3 config file (v4)
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
# Set mod key (Mod1=<Alt>, Mod4=<Super>)
set $mod Mod4
# Basic script to kill all old bars and launch new.
# Terminate already running bad instances
killall -q polybar
if type "xrandr"; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar --reload example &
done
else
;=====================================================
;
; To learn more about how to configure Polybar
; go to https://github.com/jaagr/polybar
;
; The README contains alot of information
;
;=====================================================
[colors]
@apkostka
apkostka / titlecase.pipe.ts
Last active November 9, 2017 01:12
Angular 2 pipe to transform string to Title Case
import {Pipe, PipeTransform} from 'angular2/core';
/*
* Changes the case of the first letter of a given number of words in a string.
*/
@Pipe({name: 'titleCase', pure: false})
export class TitleCase implements PipeTransform {
transform(input:string, length: number): string{
return input.length > 0 ? input.replace(/\w\S*/g, (txt => txt[0].toUpperCase() + txt.substr(1).toLowerCase() )) : '';
@apkostka
apkostka / wait-for-snapshot.js
Created November 12, 2015 22:53
PhantomJS script to wait until geo snapshot is taken.
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param onReady what to do when testFx condition is fulfilled,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
@apkostka
apkostka / do_something.js
Created September 24, 2015 22:57
Do Something
function do_something() {
alert('hi!');
}
@apkostka
apkostka / README.md
Last active September 2, 2015 23:21
Train Window

This is a train window.

@apkostka
apkostka / Brackets Balanced
Created February 12, 2014 18:55
Algorithm to determine if brackets are balanced in a string
function balanced(str){
var opens = ['{','(','['],
closes = ['}',')',']'],
split = str.split(''),
stack = [];
for (var i = 0; i < split.length - 1; i++){
if (opens.indexOf(split[i]) >= 0){
stack.push(split[i]);
} else if (closes.indexOf(split[i]) >= 0) {
@apkostka
apkostka / Ajax Multiple
Created February 12, 2014 01:35
Wait for multiple AJAX calls using jQuery
/* 'promises' can be thought of as an array of eventual values, and
* calling '.then()' of any one of those values would allow us to execute some event once the value
* has been fulfilled, i.e. once our AJAX call has provided us with a response.
*
* By calling 'apply()' on '$.when', we can call 'then()' for all members of promises, meaning we
* can wait until each call has been completed and a value has been returned.
*/
var promises = [
$.ajax('http://api.endpoint.com?type=data1'),