Skip to content

Instantly share code, notes, and snippets.

View DamirSvrtan's full-sized avatar
🎖️

Damir Svrtan DamirSvrtan

🎖️
View GitHub Profile
@DamirSvrtan
DamirSvrtan / gem_builder.sh
Last active December 31, 2015 21:29
gem_builder.sh
if [ -z $1 ]; then
GEM_NAME=${PWD##*/}
else
GEM_NAME=$1
fi
GEMSPEC="$GEM_NAME.gemspec"
if [ -f $GEMSPEC ];then
gem build $GEMSPEC
@DamirSvrtan
DamirSvrtan / creative_connect.rb
Created November 16, 2013 15:05
Short script so my linux mint 15 laptop can automatically connect to my creative D80 bluetooth speakers via bluez-tools (sudo apt-get install bluez-tools).
BLUETOOTH_MAC_ADDRESS = "00:02:02:33:B1:87"
SINK_NAME = "bluez_sink.00_02_02_33_B1_87"
def connect
`bt-audio -c #{BLUETOOTH_MAC_ADDRESS}`
end
def disconnect
`bt-audio -d #{BLUETOOTH_MAC_ADDRESS}`
end
@DamirSvrtan
DamirSvrtan / JS to ERB
Created May 26, 2012 23:11
Take the variable proba and put it in to the Representative.get brackets
<script>
function getJson(){
var proba='http://0.0.0.0:4568/;
var stuff = <%= Representative.get('http://0.0.0.0:4568/') %>;
var data = "data:image/jpeg;base64, "+stuff.imageBase64;
setTimeout(function(){document.getElementById("X_Axis").value=stuff.acceleration.X_Axis}, 200);
setTimeout(function(){document.getElementById("Y_Axis").value=stuff.acceleration.Y_Axis}, 400);
setTimeout(function(){document.getElementById("Z_Axis").value=stuff.acceleration.Z_Axis}, 600);
setTimeout(function(){document.getElementById("Latitude").value=stuff.latitude}, 800);
setTimeout(function(){document.getElementById("Longitude").value=stuff.longitude}, 1000);
@DamirSvrtan
DamirSvrtan / ZR.rb
Created May 15, 2012 01:40 — forked from shime/ZR.rb
ZR
require 'sinatra'
require 'rubygems'
require 'httparty'
require 'net/http'
require 'base64'
set :dump_errors, false
class Representative
include HTTParty
require 'sinatra'
require 'rubygems'
require 'httparty'
require 'net/http'
require 'base64'
set :dump_errors, false
class Representative
include HTTParty
### 1. Create user class by implementing
### a. properties
### i. user_id
### ii. username
### iii. password
### iv. email
### b. methods
### i. greet (learn user to say "Hi! My name is <name>, nice to meet you."
###
def method(stringy)
puts stringy.split(//).count('a')
end
def method(string)
puts string.reverse
end
### a) Ispišite sve brojeve od 1 do 1000 koji su djeljivi sa 13 ili 7
### b) Napravite novi rječnik koji će sadržavati dva ključa.
### Ključevi: 15, 7
###
### Pod ključem "15" u ovom hashu moraju biti svi brojevi
### od 1 do 1000 djeljivi sa 15
### Pod ključem "7" u ovom hashu moraju biti svi brojevi
### od 1 do 1000 djeljivi sa 7
### Ispišite sve brojeve od 1 do 100, svaki u svom redu
### Ispišite brojeve od 17 do 32 u jednom redu, odvojite ih zarezom
### Ispišite random brojeve od 50 do 110 u jednom redu, odvojite ih zarezom
(1..100).each do |i|
puts i
end
### Napišite program koji ce ispisivati string od 10 slova i 5 znamenki
### i to svaki put u drukcijem rasporedu
### Napišite program koji ce ispisati brojeve od 1 do 10, svaki u svom redu
print "12345abcdefghij".split(//).shuffle.join
[1,2,3,4,5,6,7,8,9,10].each do |i|