Skip to content

Instantly share code, notes, and snippets.

View thevery's full-sized avatar

Ildar Karimov thevery

  • Saint-Petesrburg
View GitHub Profile
import static groovyx.gpars.GParsPool.withPool
def words = """The xxxParallel() methods have to follow the contract of their non-parallel peers. So a collectParallel() method must return a legal collection of items, which you can again treat as a Groovy collection. Internally the parallel collect method builds an efficient parallel structure, called parallel array, performs the required operation concurrently and before returning destroys the Parallel Array building the collection of results to return to you. A potential call to let say findAllParallel() on the resulting collection would repeat the whole process of construction and destruction of a Parallel Array instance under the covers. With Map/Reduce you turn your collection into a Parallel Array and back only once. The Map/Reduce family of methods do not return Groovy collections, but are free to pass along the internal Parallel Arrays directly. Invoking the parallel property on a collection will build a Parallel Array for the collection and return a t
import static groovyx.gpars.GParsPool.withPool
def words = "This is just a plain text to count words in".tokenize()
print count(words)
def count(arg) {
withPool {
return arg.parallel
.map{[it, 1]}//probably implicit new MapEntry(it, 1) is better
// .groupBy{it[0]} - this should be implicit
<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:variable name="with" select="'translation.xml'"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
@thevery
thevery / RoboBaseAdapter.java
Created January 30, 2011 00:19
RoboBaseAdapter for RoboGuice
package roboguice.astroboy;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.google.inject.internal.Nullable;
import roboguice.inject.InjectView;
package roboguice.astroboy;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import roboguice.inject.InjectView;
import java.util.List;
package roboguice.astroboy;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import roboguice.inject.InjectView;
import java.util.List;
calc per 100k salary
2015/2016 average daily:
100000*12/(12*29.4) = 3401,3605442
2015 dec:
workday: 100000/23 = 4347,826087
vacation (the same): 3401,3605442
1 day vacation: 4347-3401 = 946,4655428 ~=0.95%
@thevery
thevery / DrivingInUS.md
Last active February 7, 2019 15:14
Notices about driving in US
  • Нерегулируемые перекрёстки обычно обозначаются знаком Stop (и часто дополнительной табличкой 4-way/all way), на них действует правило FIFO - кто первый приехал на перекрёсток, тот первым и уехал с него. Останавливаться, конечно, нужно обязательно.
  • Иногда одна дорога бывает условно-главной или строго второстепенной и тогда stop стоит только на другой, определить наличие знака справа-слева помогает наличие стоп-линии и слова STOP на асфальте. На второй год вождения на больших дорогах без STOP-а я на перекрёстках уже не тормозил :)
  • Yield - уступи дорогу.
  • Пешеходный перевод часто бывает не зеброй, а просто двумя параллельными линиями. - Ildar Karimov
  • Регулируемые перекрёстки похожи на наши, но светофор и знаки располагаются за перекрёстком. Из важных отличий:
  • Для поворота налево в 90% случаев есть отдельная полоса (расширение дороги либо специальная жёлтая разметка) и отдельный светофор из трёх секций (все три в виде стрелки). Если красной стрелки нет, значит поворачивать нужно как в России
@thevery
thevery / build-wget-static.sh
Created October 23, 2021 22:55
wget static build for macos
export PREFIX=$HOME/prefix/usr
curl -L https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1l.tar.gz -o openssl.tar.gz
tar xf openssl.tar.gz
cd openssl-OpenSSL_1_1_1l
./config --prefix=$PREFIX
make install_sw
cd ..
curl https://ftp.gnu.org/gnu/wget/wget-1.21.2.tar.gz -o wget.tar.gz