Skip to content

Instantly share code, notes, and snippets.

View valerianpereira's full-sized avatar
🎯
Focusing

Valerian Pereira valerianpereira

🎯
Focusing
View GitHub Profile
/*
* Display the array in a formatted manner
* Skip the struggle reading the array unformatted.
* Usage: rPrint($arrayElement);
*/
function rPrint($arr) {
echo '<pre>';
print_r($arr);
echo '</pre>';
}
@valerianpereira
valerianpereira / ruby_apicall.rb
Created October 10, 2018 07:19
ruby API call function
require 'net/http'
require 'json'
#Rail API to be added here
url = 'You can find http API url from http://indianrailapi.com/IndianRail/API'
#Prepare and Execute the action
uri = URI(url)
response = Net::HTTP.get(uri)
@valerianpereira
valerianpereira / nodejs_apicall.js
Created October 10, 2018 07:21
Making an API call in NodeJs using https package
const https = require('https');
const URL = 'You can find http API url from https://indianrailapi.com/api-collection';
https.get(URL, (resp) => {
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
resp.on('end', () => {