Skip to content

Instantly share code, notes, and snippets.

View DamirSvrtan's full-sized avatar
🎖️

Damir Svrtan DamirSvrtan

🎖️
View GitHub Profile
### Brojčano na ekranu ispišite koliko godina ima sekundi.
### Koliko imate godina ako ste stari 8286 dana?
print 365*24*60*60
print 8286/365
### Ispišite svoje ime i prezime unatrag
### Ispišite trece slovo svog imena velikim slovom
print "Damir Svrtan".reverse
print "Damir"[2].capitalize
### 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|
### 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
### 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
def method(stringy)
puts stringy.split(//).count('a')
end
def method(string)
puts string.reverse
end
### 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."
###
require 'sinatra'
require 'rubygems'
require 'httparty'
require 'net/http'
require 'base64'
set :dump_errors, false
class Representative
include HTTParty
@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
@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);