Skip to content

Instantly share code, notes, and snippets.

View praserocking's full-sized avatar
😐
you too, Github!

Shenbaga Prasanna praserocking

😐
you too, Github!
View GitHub Profile
@praserocking
praserocking / collatz.rb
Last active December 13, 2019 09:50
Collatz Conjecture
# Collatz Conjecture
n = gets.chomp.to_i
loop do
break if n == 1
n = n%2 == 0 ? n/2 : 3*n+1
p n
end
def add(a,b)
a-b
end
def multiply(a,b)
result = 0
a.times do
result = add(result, b)
end
b
def add(a,b)
a+b
end
def multiply(a,b)
result = 0
a.times do
result = add(result, b)
end
b
def add(a,b)
a+b
end
<?php
require_once "listwiki.php";
$test=new ListWiki("http://en.wikipedia.org/wiki/PHP");
echo $test->getJSON(); //Returns the wiki's textual content as JSON
print_r($test->getArray()); //Returns the wiki's textual content as PHP Array
<?php
$gcm= new GCMUtility('<your api key>');
$gcm->set_time_to_live(<seconds>); //*** optional parameter : int
$gcm->set_restricted_package_name(<restricted package name>); //*** optional parameter: string
$gcm->set_device_ids(<device IDs given by GCM>); // mandatory parameter: either array of strings or a string
$gcm->set_message(<message to be sent>); // mandatory parameter: either a string or array of string with string keys ;example: array("number":"345");
if($gcm->send())echo "Message Sent";
else echo "Message Sending not Successful";
<?php
$start=115014000; // Starting Registration Number
$dbh=mysqli_connect("localhost","root","","sastra");
for($i=0;$i<119;$i++){ //119 people at ICT
$start=$start+1;
$ch=curl_init();
set_time_limit(0);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_USERAGENT," Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 ");
curl_setopt($ch,CURLOPT_URL,"http://www.sastra.edu/result13/");
window.onload = function(){
new JsDatePick({
useMode:2, //These are options available for the Date Picker! know more about them on link below!
target:"date", //ID of the textbox to which you want to apply the Date Picker
dateFormat:"%Y-%m-%d", //Date format: here I gave as YYYY-MM-DD. to change this to DD-MM-YYYY use %d-%m-%Y
limitToToday:true //Limit date to the current system date so that user cannot select the future dates
});
}
<script type="text/javascript" src="js/jquery.1.4.2.js"></script>
<script type="text/javascript" src="js/jsDatePick.jquery.min.1.3.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/jsDatePick_ltr.min.css" />
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
}); //jquery