16
Beginner's Corner / Re: java search database
« on: September 01, 2015, 02:33:46 PM »
Can you post your code? it helps in understanding your question.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'etc'
require 'net/http'
require 'fileutils'
require 'configparser'
class Weather
def initialize(location, link)
@location = location
@link = link
@data = get_data
end
def kelvin_to_celcius(kelvin)
((kelvin - 273.15) * 1).round.to_s
end
def get_data
uri = URI(@link + @location)
Net::HTTP.get(uri)
end
def get_degrees
json = JSON.parse( @data )
kelvin_to_celcius(json["main"]["temp_min"].to_i)
end
def to_s
get_degrees + "°C In " + @location
end
end
conf_dir = '/home/' + ENV['USER'] + '/.weatherdzen/'
unless File.exists? conf_dir
FileUtils.mkpath conf_dir
FileUtils.touch conf_dir + 'config'
File.open(conf_dir + 'config', "w") do |f|
f.puts('[basic]')
f.puts('location=Antwerp')
f.puts('notify=notifysend')
f.close
end
end
cfg = ConfigParser.new(conf_dir + 'config')
weather = Weather.new(
cfg["basic"]["location"],
"http://api.openweathermap.org/data/2.5/weather?q="
)
notifier = cfg["basic"]["notify"]
wtr = weather.to_s
if notifier == "dzen"
exec 'echo ' + wtr + '| dzen2 -title-name "brightness" -l 3 -bg "#263238" -fg "#b1fff8" -x 790 -y 480 -w 270 -h 70 -p 3 -e'
elsif notifier == "notifysend"
exec 'notify-send "' + wtr + '"'
end
<?php if($leet == true): ?>
<form method="post" action="leetscript.php">
<input type="text" name="something"/>
</form>
<?php endif; ?>