Azlyrics

My personal mod for a full-screen non-scrollable AzLyrics page:

javascript: (function() {
    var h = document.getElementsByTagName('head')[0],
        s = document.createElement('style');
    s.setAttribute('type', 'text/css');
    s.appendChild(document.createTextNode('.main-page {margin:0 auto; padding: 0; width:100%}.row{margin: 0 auto}col-xs-12 col-lg-8 text-center{padding:0} body > div.container.main-page > div > div.col-xs-12.col-lg-8.text-center > div:nth-child(8){column-count: 3;line-height: 18px;height: 430px;font-size: 18px;}'));
    h.appendChild(s);
})()
Standard

Dark-mode any website

Just add this to your favorites bar and click it whenever you feel like getting back in black 😉

javascript: (function() {
    var h = document.getElementsByTagName('head')[0],
        s = document.createElement('style');
    s.setAttribute('type', 'text/css');
    s.appendChild(document.createTextNode('html{-webkit-filter:invert(100%) hue-rotate(180deg) contrast(70%) !important; background: #000;} .line-content {background-color: #fefefe;}'));
    h.appendChild(s);
})()
Standard

7 Tough Truths About The Programming Career

Programming is the sort of career that if you don’t do it right, you gonna mess yourself up pretty badly.

This is a long-term game. You need to craft the right habits that will mold you everyday into following the right path.

1. Programming is a physically demanding activity. Good exercise and good sleep are essential for any programmer. Sit with your back straight. Take a break every 30 minutes. Drink lots of liquids. Take walks and get exposed to sunshine. You have to protect your body from getting deteriorated and destroyed into the shape of a chair.

2. Adopt a get-it-done attitude. Get things out the door. Get your eye on the go and than reverse engineer it. Don’t keep working on some strange small stupid little bug or problem for hours and hours trying to solve some puzzle you created in your head. Don’t over-romanticize the technology. Don’t keep working on something that never really ships. Be result-oriented.

3. Keep it simple and consistent. Don’t over-engineer your code. Don’t try to show-off how smart you are. That works against you.

4. Allow yourself to get in the “zone”. Have long stretches of time without interruption. 3 to 4 hours of specific undisturbed time to be productive. Build large abstractions and metal blocks in your head.

5. Always be learning. Sharpen yourself. Don’t get stuck in a certain routine. Be able to debug. Be able to learn a new environment, understand how the system was put together and diagnose it.

6. Collaboration. Don’t try to be that lone hacker. Don’t stay stuck on something without reaching for help. Programming is very much a team sport. You’re a team player in the digital domain.

7. Programming is a lonely activity. Probably one of the loneliest careers. Get used to be spending lots of time in your own. Lots of times in the digital world. It’s not a social job.

Standard

Codility – Demo Tast – MissingInteger

Task description

Write a function:

class Solution { public int solution(int[] A); }

that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.

For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.

Given A = [1, 2, 3], the function should return 4.

Given A = [−1, −3], the function should return 1.

Write an efficient algorithm for the following assumptions:

  • N is an integer within the range [1..100,000];
  • each element of array A is an integer within the range [−1,000,000..1,000,000].

Solution in C#:

using System;
using System.Collections.Generic;
using System.Linq;

class Solution {
    public int solution(int[] A) {

        var result = -1;        
        A = A.OrderBy(x => x).ToArray();
        
        var max = A.Max();
        var min = A.Min();
        
        if (min > 1) return 1;
        if (A.Length == 2 &amp;&amp; min < 0 &amp;&amp; max &gt; 1) return 1;
        
        for (int i = 0; i < A.Length-1;  i++) {
            if (A[i] < 0) continue;
            if (A[i+1]-A[i] &gt; 1){
                result = A[i]+1;
                break;
            }
        }
        
        if (result == -1)
            if (max <= 0) result = 1;
            else if(min &gt; 1) result = 1;
            else result = max+1;

        return result;
    }
}

Standard