Skip to content

Instantly share code, notes, and snippets.

@NIA
NIA / PreprocessorTest.cs
Created February 8, 2018 14:20
Test case for Consulo C# preprocessor
namespace config {
class Quix{}
#define FOO_BAR
#if FOO_BAR
// active block
class FooBar{
}
@NIA
NIA / read-format-write.cpp
Last active February 2, 2016 10:14
qt data piping example
#include <QObject>
class Receiver : public QObject {
Q_OBJECT
// ...
signals:
void bytesReceived(QByteArray b);
// ...
}
@NIA
NIA / signs.txt
Created January 11, 2016 06:54
Frequently used typography symbols (not accessible from Windows keyboard)
Useful symbols:
~~~~~~~~~~~~~~
–—‒ - dash (en/em/figure)
“”«» - quotes (english/russian)
©®™ - copyright
←↑→↓ - arrows
↖↗↘↙ - arrows giagonal
⇐⇑⇒⇓⇔⇕ - arrows double
×⋅ - multiplication
… - ellipsis
@NIA
NIA / koans_solved_output.txt
Last active December 15, 2015 11:17
Scala Koans (Dec 2015)
[info] Koans: (http://scalakoans.webfactional.com)
[info] AboutAsserts:
[info] - asserts can take a boolean argument
[info] - asserts can include a message
[info] - true and false values can be compared with should matchers
[info] - booleans in asserts can test equality
[info] - sometimes we expect you to fill in the values
[info] AboutValAndVar:
[info] - Vars are variables, and may be reassigned
[info] - vals are values, and may not be reassigned, analogous to final in Java
@NIA
NIA / arrows.scala
Last active December 14, 2015 11:10
Scala hieroglyph experiments
import language.{postfixOps,implicitConversions}
case class -->[A, B] (from: A, to: B)
implicit class ArrowSugar[A](private val self: A) { def --> [B] (other: B) = new -->(self, other)}
def diff(arrow: Int-->Int) = arrow match {
case x --> y => y - x
}
diff(1 --> 4) should be (3)
@NIA
NIA / formulae.tex
Last active August 29, 2015 14:20
LaTeX math: Две выровненные системы из пары уравнений каждая с { слева и со знаком ⇔ между ними
\[
\left\{
\begin{aligned}[c]
\partial_b \eta_{ab} &= 0\\
\partial_b \delta T_{ab} &= 0
\end{aligned}
\right.
\quad \Leftrightarrow \quad
\left\{
\begin{aligned}[c]
@NIA
NIA / whichpkg.sh
Created March 19, 2015 09:50
whichpkg: who installed this command?
# whichpkg: which package installed this command?
# Detects builtins and follows symlinks. Add the code below to .bashrc/.bash_aliases
# Usage examples:
#
# nia$ whichpkg vim
# vim-gtk: /usr/bin/vim.gtk
#
# nia$ whichpkg type
# type встроена в оболочку
#
@NIA
NIA / diagram.png
Last active October 20, 2021 09:55
A simple class diagram using LaTeX+TikZ+tikz-uml.sty
diagram.png
@NIA
NIA / gist:25560a3580e3872557a9
Last active August 29, 2015 14:00
Draft of suggested edit to answer (http://stackoverflow.com/a/23444489/693538)

You can try with QByteArray that shares same QString's interface but is more suitable for performance issues.I obtain 36 ms (qt 5.2 clang) vs. your original 57 ms (on my machine) with this code:

QByteArray allDatab;
foreach(const int & value, values) {
    allDatab += QByteArray::number(value);
    allDatab += '\n';
}
QString result(allDatab);

and 29 ms with this version (that maybe confirm your assumptions about setNum):

@NIA
NIA / truecolor.rb
Last active December 25, 2015 09:19
Simple colorizer of tests output: given test program printing true or false for test passing, it paints "true" green and "false" red
#!/usr/bin/env ruby
# Usage example: echo 'use "hw1test.sml";' | sml | truecolor.rb
require 'colorize'
# HA HA HA I USE GLOBAL VARIABLES
$failed = 0
$passed = 0
while line = gets