Skip to content

Instantly share code, notes, and snippets.

@NIA
NIA / PreprocessorTest.cs
Created Feb 8, 2018
Test case for Consulo C# preprocessor
View PreprocessorTest.cs
namespace config {
class Quix{}
#define FOO_BAR
#if FOO_BAR
// active block
class FooBar{
}
@NIA
NIA / read-format-write.cpp
Last active Feb 2, 2016
qt data piping example
View read-format-write.cpp
#include <QObject>
class Receiver : public QObject {
Q_OBJECT
// ...
signals:
void bytesReceived(QByteArray b);
// ...
}
@NIA
NIA / signs.txt
Created Jan 11, 2016
Frequently used typography symbols (not accessible from Windows keyboard)
View signs.txt
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 Dec 15, 2015
Scala Koans (Dec 2015)
View koans_solved_output.txt
[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 Dec 14, 2015
Scala hieroglyph experiments
View arrows.scala
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 Aug 29, 2015
LaTeX math: Две выровненные системы из пары уравнений каждая с { слева и со знаком ⇔ между ними
View formulae.tex
\[
\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 Mar 19, 2015
whichpkg: who installed this command?
View whichpkg.sh
# 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 Oct 20, 2021
A simple class diagram using LaTeX+TikZ+tikz-uml.sty
View gist:25560a3580e3872557a9

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 Dec 25, 2015
Simple colorizer of tests output: given test program printing true or false for test passing, it paints "true" green and "false" red
View truecolor.rb
#!/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