Skip to content

Instantly share code, notes, and snippets.

View dant3's full-sized avatar

Viacheslav Blinov dant3

View GitHub Profile
@dant3
dant3 / fun.cpp
Last active March 8, 2024 06:15
Some fun with C++ 11 - fold, map, reduce, mkString for std::vector<T>
#include <iostream>
#include <sstream>
#include <functional>
#include <vector>
template <typename T, typename U>
U foldLeft(const std::vector<T>& data,
const U& initialValue,
const std::function<U(U,T)>& foldFn) {
typedef typename std::vector<T>::const_iterator Iterator;
@dant3
dant3 / MarkdownComposer.kt
Created November 22, 2023 12:16 — forked from ErikHellman/MarkdownComposer.kt
A simple rendered for Markdown text parsed using CommonMarks
package se.hellsoft.markdowncomposer
import android.util.Log
import androidx.compose.foundation.Box
import androidx.compose.foundation.ContentGravity
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.material.Colors
@dant3
dant3 / nullable.kt
Created August 4, 2017 12:38
Check if kotlin generic is nullable type
inline fun <reified T> isNullable(): Boolean = null is T
@dant3
dant3 / hello_x32.s
Last active August 3, 2022 09:12
Hello world in assembler
segment .text ;code segment
global _start ;must be declared for linker
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
#!/bin/bash
# prerequisites
apt-get install openjdk-7-jdk
NEXUS_DIR=/opt/nexus
mkdir -p $NEXUS_DIR
curl -L http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz | tar -xzv --strip 1 -C $NEXUS_DIR
@dant3
dant3 / LogstashService.java
Last active July 21, 2021 06:43
Logstash Android client
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import java.io.*;
import java.net.*;
@dant3
dant3 / docker-for-mac.md
Created November 20, 2018 16:26 — forked from BretFisher/docker-for-mac.md
Getting a Shell in the Docker for Mac Moby VM

2018 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Moby VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@dant3
dant3 / dagger.gradle
Last active October 31, 2018 16:07
Fixes problems with Idea+Gradle+Dagger combo then you can't see generated symbols
def generatedMain = new File(buildDir, "generated/main")
compileJava {
doFirst {
generatedMain.mkdirs()
}
options.compilerArgs += ['-s', generatedMain]
}
idea {
@dant3
dant3 / build.gradle.kts
Created April 29, 2018 05:30 — forked from mkobit/build.gradle.kts
Run Kotlin REPL with built source code and main classpath in Gradle
// Assuming Kotlin plugin is applied...
// Run as: ./gradlew kotlinRepl --console plain --no-daemon
val kotlinRepl by tasks.creating {
description = "Starts Kotlin REPL with compiled main classes and runtime classpath"
val mainSourceSet = java.sourceSets["main"]
dependsOn(mainSourceSet.output)
doFirst {
val buildscriptClasspath = rootProject.buildscript.configurations["classpath"]
@dant3
dant3 / docker-examples.md
Created April 26, 2018 13:21 — forked from thaJeztah/docker-examples.md
Some docker examples

Commit, clone a container

To 'clone' a container, you'll have to make an image of that container first, you can do so by "committing" the container. Docker will (by default) pause all processes running in the container during commit to preserve data-consistency.

For example;

docker commit --message="Snapshot of my container" my_container my_container_snapshot:yymmdd