This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(){ | |
printf("Hello World!\n"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ist(time) | |
time.in_time_zone(TZInfo::Timezone.get('Asia/Kolkata')) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def humanize secs | |
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name| | |
if secs > 0 | |
secs, n = secs.divmod(count) | |
"#{n.to_i} #{name}" | |
end | |
}.compact.reverse.join(' ') | |
end | |
p humanize 1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<script> | |
navigator.geolocation.getCurrentPosition(GetLocation); | |
function GetLocation(location) { | |
alert(location.coords.latitude); | |
alert(location.coords.longitude); | |
alert(location.coords.accuracy); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
return 0;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def sum | |
total = 0 | |
for element in self | |
total += element | |
end | |
total | |
end | |
def increment base = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#input_text').keyup(function(e) { | |
//alert(e.keyCode); | |
if(e.keyCode == 13) { | |
alert('Enter key was pressed.'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# A simple search method | |
def self.search text | |
columns = [:name, :roll_no, :address, :city, :pin, :ph] | |
words = text.downcase.split(/\s+/) | |
query_array_2 = [] | |
for word in words | |
query_array = [] | |
for column in columns | |
query_array << "lower(#{column}) like '%#{word}%'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'simple_uuid' | |
uuid = SimpleUUID::UUID.new | |
uuid.to_guid # actually this is what I have stored in my database | |
puts Time.at(SimpleUUID::UUID.new(uuid.to_guid).seconds) |
OlderNewer