Introduction

Mon 25 March 2019

Well, well, well...

Hello World.

This is my blog.

I have no idea what I am doing.

Links:

Markdown is not perfect, but well, it is ok.

Typografy quality check.

This is mostly style / theme related, but also generator side (i.e. inserting proper ampersands, non breakable spaces, justification, etc.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse porta erat id egestas--maximus. Praesent convallis at nibh feugiat luctus. Sed eget tortor rhoncus, volutpat lacus non, sollicitudin lorem. Duis posuere tellus in nulla gravida volutpat. Vivamus at dapibus quam, ut molestie lacus. Nullam nec ultricies nunc, ac aliquet nisi. Cras odio sem, sagittis ut neque eu, feugiat suscipit metus. Donec vehicula auctor rhoncus. In pretium at tellus quis gravida.1

Nullam sollicitudin erat & lectus, in sollicitudin sem hendrerit id.

Proin quis tempor urna, eget eleifend leo. Nullam tincidunt nec urna quis dignissim. Fusce accumsan magna lobortis velit dignissim, non egestas magna aliquam. Suspendisse consequat mi vitae risus tincidunt semper. Morbi eget mauris porta, viverra risus eget, hendrerit risus. Integer vel tortor est. Duis tempor placerat varius. Donec eget nisi sollicitudin, aliquet massa vitae, finibus lectus. Cras vulputate rhoncus maximus. Sed ut eleifend nibh. Mauris nisl est, fermentum fermentum 123% rutrum vitae, iaculis bibendum mauris. Aenean imperdiet in mauris aliquet gravida.

Lets also test some lines with really long words, antidisestablishmentarianism, pneumonoultramicroscopicsilicovolcanoconiosis, pneumonoultramicroscopicsilicovolcanoconiosis, Incomprehensibilities, Interdisciplinary, Inconsequential, Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon.

What is this about?

$$ \sum_{n=1}^\infty {1 \over n^2} = \frac{\pi^2}{6} $$

cute small dog smiling on a couch

Hope it does work.

  • Python:
for i in range(5):
  print('*' * i)
  print('{}'.format(list(k ** i for k in range(10) if k != i)))

@bzium('n', alias=['b', 2'])
def Add(X : [B], Y : [Imm, B] = Imm(7), *, comment=X):
  return lambda: X + Y
  • Go:
func foo(a, b int) (x int, err error) {
    if b == 0 {
        err = errors.New("nope")
        return
    }
    return a / b, nil
}
  • D:
import std.stdio;
final class A(T) {
  T a_, b_;
  /// Construct class A with a pair value (a, b).
  init(T a, T b) {
    a_ = a;
    b_ = b;
  }
  /// Return a new value with result of +, -, and * operator.
  auto opBinary(string op)(A!T y) const if (s == "+" || s == "-" || s == "*") {
    debug writefln("Doing %d " ~ s ~ " %d", this.a, y.a);
    mixin("return A!(T)(this.a " ~ op ~ " y.a, this.b " ~ op ~ " y.b);");
  }
  invariant {
    assert(a >= b);
  }
}
unittest {
  auto a = A!int(1, 2);
  auto b = A!int(3, 7);
  auto c = a + b;
  assert(c.a_ == 4);
  assert(c.b_ == 9);
}
  • Dart:
Future<void> createDescriptions(Iterable<String> objects) async {
  for (var object in objects) {
    try {
      var file = File('$object.txt');
      if (await file.exists()) {
        var modified = await file.lastModified();
        print(
            'File for $object already exists. It was modified on $modified.');
        continue;
      }
      await file.create();
      await file.writeAsString('Start describing $object in this file.');
    } on IOException catch (e) {
      print('Cannot create description for $object: $e');
    }
  }
}
  • JavaScript:
async function loadJson(url) {
  let response = await fetch(url);
  if (response.status == 200) {
    let json = await response.json();
    return json;
  }
  throw new Error(response.status);
}

loadJson('no-such-user.json')
  .catch(alert);

let group = {
  title: "Our Group",
  students: ["John", "Pete", "Alice"],
  showList() {
    this.students.forEach(
      student => alert(this.title + ': ' + student)
    );
  }
};
group.showList();
let user = { name: "John", age: 30 };
for (let [key, value] of Object.entries(user)) {
  alert(`${key}:${value}`);
}
let [name1, name2, ...rest] = ["Julius", "Caesar", "Consul", "of the Roman Republic"];
let options = {title: "Menu", ignored: "Something"};
let {width: w = 100, height: h = 200, title} = options;
  • C++
namespace std {
template <>
class numeric_limits<fmt::internal::dummy_int>
    : public std::numeric_limits<int> {
 public:
  // Portable version of isinf.
  template <typename T> static bool isinfinity(T x) {
    using namespace fmt::internal;
    if (const_check(sizeof(isinf(x)) != sizeof(fmt::internal::dummy_int)))
      return isinf(x) != 0;
    return !_finite(static_cast<double>(x));
  }
  template <typename T> static bool isnotanumber(T x) {
    using namespace fmt::internal;
    if (const_check(sizeof(isnan(x)) != sizeof(fmt::internal::dummy_int)))
      return isnan(x) != 0;
    return _isnan(static_cast<double>(x)) != 0;
  }
};
} // namespace std
  • Shell:
#!/bin/sh
A=$(egrep "$1" /etc/passwd | awk -F ':' '{print $6}')
find -type f "${A}" | while read X
do
  echo "X" "${X}" | sed -e "s,$A,,"
done
  • Rust:
use std::ops::Add;

#[derive(Debug, PartialEq)]
struct Point {
    x: i32,
    y: i32,
}

impl Add for Point {
    type Output = Point;

    fn add(self, other: Point) -> Point {
        Point {
            x: self.x + other.x,
            y: self.y + other.y,
        }
    }
}

fn main() {
    assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
               Point { x: 3, y: 3 });
}
  • SQL:
SELECT category, name, setting, unit, source,
       sourcefile || ':' || sourceline AS file
  FROM pg_settings
  WHERE source != 'default'
  ORDER BY category, name;

Table?

category name setting unit source file
Autovacuum autovacuum_max_workers 6 configuration file /etc/postgresql/11/main/conf.d/my.conf:92
Autovacuum autovacuum_naptime 3 s configuration file /etc/postgresql/11/main/conf.d/my.conf:93
Autovacuum autovacuum_vacuum_cost_delay 10 ms configuration file /etc/postgresql/11/main/conf.d/my.conf:96
Autovacuum autovacuum_vacuum_cost_limit 5000 configuration file /etc/postgresql/11/main/conf.d/my.conf:95
Autovacuum autovacuum_vacuum_scale_factor 0.1 configuration file /etc/postgresql/11/main/conf.d/my.conf:94
  • HTML:
<body>
  <script>
    var mdn = window.mdn || {};
    (function(win) {
        'use strict';
        win.mdn.features = {};
    })(this);
</script>
<div id="content" class="article text-content">
<article id="wikiArticle"><div></div>
<p>The <code>font-display</code> descriptor ...</p>

<h2 id="The_font_display_timeline">The font display timeline</h2>
<p>The font display timeline xyz:</p>
<dl>
 <dt>Font block period</dt>
 <dd>XYZ</dd>
</dl>
</article>
</div>
</body>
  • CSS:
@font-face {
  font-family: ExampleFont;
  src: url(/path/to/fonts/examplefont.woff) format('woff'),
       url(/path/to/fonts/examplefont.eot) format('eot');
  font-weight: 400;
  font-style: normal;
  font-display: fallback;
}
  • For completness, Java
public class X {
public String shortestPalindrome(String s) {
    int i=0; 
    int j=s.length()-1;

    while(j>=0){
        if(s.charAt(i)==s.charAt(j)){
            i++;
        }
        j--;
    }

    if(i==s.length())
        return s;

    String suffix = s.substring(i);
    String prefix = new StringBuilder(suffix).reverse().toString();
    String mid = shortestPalindrome(s.substring(0, i));
    return prefix+mid+suffix;
}
static void main(String[] a) {
  System.out.println(shortestPalindrome(s[0]);
}
}

  1. Some example footnote. 

blogroll

social