Skip to content

Instantly share code, notes, and snippets.

View sivasankars's full-sized avatar

SIVA SANKAR sivasankars

  • India
View GitHub Profile
@sivasankars
sivasankars / clash-of-clans-official-api-integration-on-php.php
Last active April 12, 2016 02:09
Clash of Clans Official API Integration on PHP. You can connect with API to get details about your Clans, Location and Members
<?php
//Clash of Clans Official API Integration on PHP
//Refer : http://sivasankar.in/
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_URL, 'https://api.clashofclans.com/v1/clans/%23LRQ0PJL9'); //Clan Tag
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiIsImtpZCI6IjI4YTMxOGY3LTAwMDAtYTFlYi03ZmExLTJjNzQzM2M2Y2NhNSJ9.eyJpc3MiOiJzdXBlcmNlbGwiLCJhdWQiOiJzdXBlcmNlbGw6Z2FtZWFwaSIsImp0aSI6ImVkM2UzMjEwLTVkYmItNDQ0Ni05YzA3LTZhNjhmMDExMTc1NCIsImlhdCI6MTQ1NjUwOTI4NCwic3ViIjoiZGV2ZWxvcGVyL2Y4ZTA0MGUwLTcxNzYtMjgzYi1jY2YwLTc5NzkyMWYzN2NiYSIsInNjb3BlcyI6WyJjbGFzaCJdLCJsaW1pdHMiOlt7InRpZXIiOiJkZXZlbG9wZXIvc2lsdmVyIiwidHlwZSI6InRocm90dGxpbmcifSx7ImNpZHJzIjpbIjEyMi4xNzQuMTgzLjIxMiJdLCJ0eXBlIjoiY2xpZW50In1dfQ.x_Nhtmg6MPyEGjnMNqpG0mTwAwv8x2kAuvcnvsAGN2u1AbXFTusF1mBJvqpbsHCM7eccKFySug9BKdlOSMV_9Q'
@sivasankars
sivasankars / app.js
Last active April 1, 2019 08:39
List Available Time Zone Using Moment.js (Node.js)
var moment = require('moment-timezone'); // moment-timezone
console.log(moment.tz.names()); // Get list of all available time zone names
@sivasankars
sivasankars / index.html
Created December 24, 2016 03:59
Dynamic Time Zones Dropdown Using Moment.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dynamic Time Zones Dropdown Using Moment.js</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
@sivasankars
sivasankars / function.php
Last active May 18, 2019 10:10
Integrate Contact Form 7 With 3rd Party(MSG91) In WordPress (http://sivasankar.in/integrate-contact-form-7-3rd-party-wordpress/)
<?php
/* Contact Form 7 - Hook For MSG91 */
function msg91_api($cf7) {
$wpcf = WPCF7_ContactForm::get_current();
if ($wpcf->id() == 4) {
if (get_option('enable') == '1') {
$authKey = get_option('authKey');
$mobiles = get_option('mobiles');
$senderId = get_option('senderId');
var express = require('express');
var mongoose = require('mongoose');
var gridfs = require('gridfs-stream');
var fs = require('fs');
var db_filename = "demo.jpg";
var local_file = "./gridfs.jpg";
mongoose.connect('mongodb://localhost:27017/test', { useNewUrlParser: true });
mongoose.Promise = global.Promise;
@sivasankars
sivasankars / app.js
Created February 17, 2018 04:44
Google URL Shortener
'use strict';
var express = require('express');
var { google } = require('googleapis');
// API keys, Client ID and Client Secret @ https://code.google.com/apis/console
var GAPI = "AIzaSyBheQiEQ_NYpsFugde-jb8hmC7FBAFEVHI";
var CLIENT_ID = "507857393893-tmnp49jq8of3en7m81dqdidedupris8d.apps.googleusercontent.com";
var CLIENT_SECRET = "aLHvXDEV_I_YpAA4Y9tl1tdg";
var REDIRECT_URL = "http://localhost:3000/oauth2callback";
@sivasankars
sivasankars / index.php
Last active June 12, 2018 18:08
List Posts From WordPress Using REST API With cURL In PHP (http://niralar.com/list-posts-from-wordpress-using-rest-api-with-curl-in-php/)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="List Posts From WordPress Using REST API With cURL In PHP">
<title>Demo - WordPress REST API</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
const express = require('express');
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);
// Fork workers.
@sivasankars
sivasankars / app.js
Created July 8, 2018 04:26
Best Practice of Connecting MongoDB Using Mongoose ODM
var mongoose = require('mongoose');
var express = require('express');
// Connect to MongoDB Using Mongoose ODM
mongoose.connect('mongodb://localhost:27017/integration_test', { useNewUrlParser: true });
// Listen For Mongoose Connection Error
mongoose.connection.on("error", function (err) { console.error('Failed to Connect MongoDB'); });
// Listen For Mongoose Disconnection
@sivasankars
sivasankars / app.js
Created December 6, 2018 02:46
Print Elements of a Matrix in Diagonal Order
var array = [
[[1], [2], [3], [4]],
[[5], [6], [7], [8]],
[[9], [10], [11], [12]],
[[13], [14], [15], [16]],
[[17], [18], [19], [20]]
];
function printAllDgl(array) {
var i = 0, j = 0, output = [];