Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Vilius Kraujutis ViliusKraujutis

🏠
Working from home
View GitHub Profile
@ViliusKraujutis
ViliusKraujutis / lampHolder.scad
Created Sep 1, 2017
A holder for table lamp to fit on the corner of IKEA table
View lampHolder.scad
$fn=60;
holeH=37;
holeD=12.5;
h=40;
module lampHolder() {
difference() {
holderBody();
tableSpace();
@ViliusKraujutis
ViliusKraujutis / MainActivity.java
Created Aug 16, 2017
Use RxJava to detect changes
View MainActivity.java
package lt.andro.learnrxjava;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.jakewharton.rxbinding2.InitialValueObservable;
@ViliusKraujutis
ViliusKraujutis / printer lamp handle.scad
Created Aug 4, 2017
Čia rankenėlė tai lemputei šalia spausdintuvo. Padariau kad viduje būtų apytuščia, su susiaurėjimais galuose; skylutes jungikliui ir magnetukui; taip pat padariau pussferės ir kūbiuko išėmimą lemputės galiukui.
View printer lamp handle.scad
$fn=60;
module lampHandle() {
difference() {
cylinder(d=35, h = 100);
translate([0,0,84]){
bulbSpace();
}
holoInside();
buttonHole();
@ViliusKraujutis
ViliusKraujutis / belt tensioner back
Created Jul 31, 2017
Anet A8 Y axis belt tensioner
View belt tensioner back
$fn=20;
module holder () {
difference() {
// create rounded corners cube
rcube([20, 30, 20]);
// make a hole for the screw
translate([10, 10, 0])
screwHole();
@ViliusKraujutis
ViliusKraujutis / compass.txt
Created May 28, 2017
Compass app for micro:bit which shows where's the NORTH. App reads compassHeading value and uses it to determine which LED to turn on. All 360 degrees are divided by 12 (ie. 30 degrees). 12 LEDs around the LED matrix are used to show the NORTH.
View compass.txt
let Angle = 0
basic.forever(() => {
Angle = input.compassHeading()
if (345 < Angle || Angle < 15) {
basic.showLeds(`
. . # . .
. . . . .
. . . . .
. . . . .
. . . . .
@ViliusKraujutis
ViliusKraujutis / air-sensor.ino
Created Mar 28, 2017
Air Sensor Arduino based air quality sensor Sensors used: DHT22 - temperature and humidity sensor MQ-2 - gas leakage detector. It is suitable for detecting H2, LPG, CH4, CO, Alcohol, Smoke or Propane MQ-3 - alcohol sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity…
View air-sensor.ino
/*
Air Sensor
Arduino based air quality sensor
Sensors used:
DHT22 - temperature and humidity sensor
MQ-2 - gas leakage detector. It is suitable for detecting H2, LPG, CH4, CO, Alcohol, Smoke or Propane
MQ-3 - alcohol sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity and fast response time
MQ-7 - Carbon Monoxide (CO) sensor
@ViliusKraujutis
ViliusKraujutis / BuildingRetrofit.java
Created Oct 4, 2016
Two different custom value enum serialization
View BuildingRetrofit.java
...
Gson gson = new GsonBuilder()
.registerTypeAdapter(NumberOfPeople.class, NumberOfPeople.getDeserializer())
.create();
return new Retrofit.Builder()
...
.addConverterFactory(GsonConverterFactory.create(gson))
.client(client)
.build();
@ViliusKraujutis
ViliusKraujutis / Timelapse_servo
Created May 7, 2016
Arduino Nano + 9V battery + M-1503 Servo = panoramic timelapse rotator-phone holder.
View Timelapse_servo
#include <Servo.h>
float TIMELAPSE_SPEED = 5; // N:1
long COOLDOWN = 2000 * TIMELAPSE_SPEED;
long CYCLE = 20000 * TIMELAPSE_SPEED;
long ANGLE_MIN = 45;
long ANGLE_MAX = 135;
long angleRange = ANGLE_MAX - ANGLE_MIN;
@ViliusKraujutis
ViliusKraujutis / PIR sensor for LED lighting
Created May 2, 2016
Attached PIR sensor to Arduino, so it could adjust power 12V ~18W LED lamp sticker-strip under kitchen's cupboards. Just a simple, although interesting project combining electronics, automation and programming.
View PIR sensor for LED lighting
int relayPin = 3;
int pirPin = 2;
int ledPin = 13; // just a LED on Arduino board. Not that huge ~18W LED lamp.
long lastDetection = 0; // millis
long DELAY = 3 * 1000; // N seconds (also adjustable at PIR sensor too)
void setup() {
pinMode(relayPin, OUTPUT);
pinMode(pirPin, INPUT);
@ViliusKraujutis
ViliusKraujutis / Solution.java
Last active Apr 22, 2016
Codility solution https://codility.com/demo/results/demoGYMPA6-Q73/ Take your own here: https://codility.com/demo/take-sample-test/ This is a demo task. You can read about this task and its solutions in this blog post: http://dev.tasubo.com/2012/09/tips-for-tasks-on-codility.html
View Solution.java
class Solution {
public int solution(int[] A) {
long left = 0;
long right = 0;
long sum = sum(A);
for (int i = 0; i < A.length; i++) {
right = sum - left - A[i];
if (left == right)