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 / vlcsms.c
Last active August 29, 2015 14:22 — forked from TimSC/vlcsms.c
//To compile:
//cc vlcsms.c -o vlcsms -lvlc
//This source is by Tim Sheerman-Chase and it is released as public domain.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <vlc/vlc.h>
@dant3
dant3 / HelloLanterna3.scala
Last active December 19, 2017 16:17
Hello world, in Lanterna 3
import com.googlecode.lanterna.TextColor
import com.googlecode.lanterna.gui2._
import com.googlecode.lanterna.screen.Screen
import com.googlecode.lanterna.screen.TerminalScreen
import com.googlecode.lanterna.terminal.DefaultTerminalFactory
object Main {
def main(args:Array[String]) = {
val terminalFactory = new DefaultTerminalFactory
terminalFactory.setSuppressSwingTerminalFrame(true)
@dant3
dant3 / ListAdapter.scala
Created July 14, 2015 21:07
Lanterna 2 ListView & ListAdapter - a very simple version
trait ListAdapter[+T] extends Reactive {
def isEmpty:Boolean = size <= 0
def indexes:Range = 0 to maxIndex step 1
def maxIndex:Int = size - 1
def apply(index: Int):T = item(index)
def size:Int
def item(index: Int):T
def createItemString(index: Int): String
}
@dant3
dant3 / typedactordemo.scala
Last active August 28, 2015 15:38 — forked from rkuhn/typedactordemo.scala
TypedActor Demonstration
package typedactordemo
import akka.actor._
import akka.dispatch.Future
import akka.pattern.ask
import akka.util.Timeout
import akka.util.duration._
case class Request(payload: String)
case class Response(payload: String)
@dant3
dant3 / adbwifi.sh
Last active September 9, 2015 09:37
ADB over wifi
#!/bin/bash
PORT=5555
echo "Getting device ip..."
PHONE_IP=`adb shell ip -f inet addr show wlan0 | grep inet | cut -d: -f2 | awk '{ print $2 }' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"`
echo "Device ip: $PHONE_IP"
echo "Enabling adb tcpip on port $PORT"
adb tcpip $PORT
echo "adb tcpip enabled. Connecting..."
adb connect $PHONE_IP:$PORT
echo "Adb over wifi connected. Now you can remove your usb cable."
@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 / type-bounds.scala
Created September 29, 2015 22:08 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@dant3
dant3 / travis.yml
Created May 4, 2016 15:44
sbt-android initial travis.yml
language: android
os:
- linux
jdk:
- oraclejdk8
cache:
directories:
- $HOME/.m2/repository
- $HOME/.sbt
- $HOME/.ivy2
@dant3
dant3 / wercker.yml
Created May 4, 2016 16:05
Wercker based ci configuration for sbt-android
box: dant3/android
build:
steps:
- script:
name: install sbt-launcher
code: |
curl -o sbt-launcher.sh https://raw.githubusercontent.com/paulp/sbt-extras/master/sbt
chmod a+x ./sbt-launcher.sh
- script:
name: start emulator for tests