Skip to content

Instantly share code, notes, and snippets.

View dant3's full-sized avatar

Viacheslav Blinov dant3

View GitHub Profile
/**
* Copyright 2013 John Smith
*
* This file is part of Jewelsea Tic-Tac-Toe.
*
* Jewelsea Tic-Tac-Toe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@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 / 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 / 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 / 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
apply plugin: "java"
apply plugin: "eclipse"
repositories {
mavenCentral()
}
dependencies {
compile (
"org.jboss.netty:netty:latest.integration",
@dant3
dant3 / build.gradle
Last active December 23, 2015 09:07
lombok + gradle
apply plugin: 'java'
apply from: 'provided.gradle'
repositories {
mavenCentral()
}
dependencies {
provided group: 'org.projectlombok', name: 'lombok', version:'1.14.8'
}
@dant3
dant3 / mvncolor.sh
Created October 24, 2013 06:46 — forked from katta/mvncolor.sh
#!/usr/bin/env bash
# Formatting constants
export BOLD=`tput bold`
export UNDERLINE_ON=`tput smul`
export UNDERLINE_OFF=`tput rmul`
export TEXT_BLACK=`tput setaf 0`
export TEXT_RED=`tput setaf 1`
export TEXT_GREEN=`tput setaf 2`
export TEXT_YELLOW=`tput setaf 3`
@dant3
dant3 / Jsson.scala
Created November 11, 2013 21:25 — forked from kmizu/Jsson.scala
import scala.util.DynamicVariable
/**
* A concise JSON DSL in Scala.
* When you want to use, only
* import Jsson._ is needed.
* Note that this program change the semantics of standard -&gt; operator.
* I recommend that you use enclosing block with Jsson as followings:
* {
* import Jsson._
* val obj = %{
@dant3
dant3 / json.scala
Created November 12, 2013 19:01
Json.scala
def json(foo:String, bar:String) =
f"""{
| "commands" : [{
| "type" : "set_user_data",
| "user_data" : {
| "foo" : $foo%s,
| "bar" : $bar%s
| }
| }]