Skip to content

Instantly share code, notes, and snippets.

View YugalXD's full-sized avatar
💭
yugalxd@github:~$ profile

Yugal Yadav YugalXD

💭
yugalxd@github:~$ profile
View GitHub Profile
@YugalXD
YugalXD / time.js
Created December 15, 2015 11:26
get relative time in js
function relative_time(date_str) {
if (!date_str) {return;}
var parsed_date = date_str;
var relative_to = (arguments.length > 1) ? arguments[1] : new Date(); //defines relative to what ..default is now
var delta = parseInt((relative_to.getTime()-parsed_date)/1000);
delta=(delta<2)?2:delta;
var r = '';
if (delta < 60) {
r = delta + ' seconds ago';
} else if(delta < 120) {
@YugalXD
YugalXD / zsh.md
Created February 15, 2016 10:35 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@YugalXD
YugalXD / reletive.php
Created April 20, 2016 09:48
Facebook like reletive time in PHP
function getmychattime($datetime){
$timestamp = strtotime($datetime);
$now = time();
$diff = $now - $timestamp;
if ($diff < 60){
return date('g:ia',$timestamp);
}
$diff = floor($diff/60);
if ($diff < 60){
return date('g:ia',$timestamp);
@YugalXD
YugalXD / function.php
Created April 26, 2016 10:04
Send mail with mailgun api by PHP CURL.
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/DOMAIN_NAME');
define('MAILGUN_KEY', 'KEY');
function sendmailbymailgun($to,$toname,$mailfromnane,$mailfrom,$subject,$html,$text,$tag,$replyto){
$array_data = array(
'from'=> $mailfromname .'<'.$mailfrom.'>',
'to'=>$toname.'<'.$to.'>',
'subject'=>$subject,
'html'=>$html,
@YugalXD
YugalXD / bulkmailbymailgun.php
Created April 27, 2016 06:12
Send bulk mail by mailgun api in php
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/DOMAIN_NAME');
define('MAILGUN_KEY', 'KEY');
function sendBulkMailByMailGun($emailArr = array(), $subject, $html, $text = '', $replyto = EMAIL_INFO, $mailcat = 'test', $mailfrom = FROM, $mailfromname = FROMNAME) {
$emails_arr = array();
if ($emailArr) {
$i=1;
foreach ($emailArr as $email) {
@YugalXD
YugalXD / maindb.sql
Created May 25, 2016 10:54
EJABBERD mysql
CREATE TABLE users (
username varchar(191) PRIMARY KEY,
password text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- To support SCRAM auth:
-- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT '';
@YugalXD
YugalXD / ejabberd.yml
Last active May 25, 2016 12:47
ejabberd configuration file by webmasters.help
###
###' ejabberd configuration file
###
###
### The parameters used in this configuration file are explained in more detail
### in the ejabberd Installation and Operation Guide.
### Please consult the Guide in case of doubts, it is included with
### your copy of ejabberd, and is also available online at
### http://www.process-one.net/en/ejabberd/docs/

#MongoDB - Setting up a Replica Set

cd \mongodbdir\

mkdir db1
mkdir db2
mkdir db3

###Primary mongod --dbpath ./db1 --port 30000 --replSet "demo"

# check for updates
sudo apt-get update
sudo apt-get upgrade
# install necessary software
sudo apt-get install mysql-server apache2 php5 libapache2-mod-php5 php5-mysql libapache2-mod-auth-mysql php5-curl git sendmail
sudo apt-get install php-apc
# create DB
echo "CREATE DATABASE OpenVBX; GRANT ALL PRIVILEGES ON OpenVBX.* TO ubuntu@localhost IDENTIFIED BY {PASSWORD_HERE}; FLUSH PRIVILEGES" | sudo mysql -p
@YugalXD
YugalXD / multi-git.md
Created January 16, 2017 12:58 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer.

Setting up github and bitbucket on the same computer

Github will be the main account and bitbucket the secondary.

Create SSH Keys

ssh-keygen -t rsa -C "github email"

Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.