Skip to content

Instantly share code, notes, and snippets.

<?php
/*$date = new DateTime('2017-12-21T01:30:00.0000000', new DateTimeZone('Asia/Kolkata'));
echo "Indian time:". $date->format("Y-m-d H:i:s P");echo "<br>";
$date->setTimeZone(new DateTimeZone('America/New_York'));
echo date('Y-m-d H:i:s', strtotime('2017-12-21T01:30:00.0000000') + (5.5 * 3600));*/
/*$a = function() {
echo 'hello world';
};
@ManishLSN
ManishLSN / tmux-cheatsheet.markdown
Created December 8, 2017 06:37 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ManishLSN
ManishLSN / curlMethod.php
Created November 23, 2017 09:51
curl method in php
<?php
### function for curl ###
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
@ManishLSN
ManishLSN / setheaderbyangular.js
Created November 23, 2017 09:48
set header in angular for token
//$window.location.reload();
//$state.go("login");
$cookies.put("token", response.token);
var value = $cookies.get("token");
/* $cookies.put("loginUserId", response[0].id);
$rootScope.loginUserId = $cookies.get("loginUserId"); */
localStorageService.set("loginUserId", response.id);
@ManishLSN
ManishLSN / webnotification.html
Created November 22, 2017 14:24
to show custom and predefined webnotification code
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Web Notifications API Demo</title>
<style>
*
{
-webkit-box-sizing: border-box;
@ManishLSN
ManishLSN / Converter.class.php
Created November 22, 2017 12:07 — forked from gabrieljmj/Converter.class.php
Currency converter using Google API You must have the curl extension in PHP active.
<?php
/**
* @author @GabrielJMJ /twitter
* @description Abstract class to define a interface of a converter
* @link https://gist.github.com/GabrielJMJ/6977968 Gist on GitHub
**/
abstract class Converter{
protected $valueWithCurrency;
protected $toCurrency;
@ManishLSN
ManishLSN / getDistance.php
Created November 13, 2017 14:50
get the distance from two geo location point
<?php
// $details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&mode=driving&sensor=false";
//you can also pass latitude/longitude values in origins
// $details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=41.43206,-81.38992&destinations=San+Francisco&mode=driving&sensor=false";
// $details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=indore+mp&destinations=dewas+mp&mode=driving&sensor=false";
$details = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=22.720816,75.874925&destinations=22.721786,75.878326&mode=driving&sensor=false";
@ManishLSN
ManishLSN / postgres-cheatsheet.md
Created September 15, 2017 06:21 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@ManishLSN
ManishLSN / replace_str_inFile.php
Created September 11, 2017 13:41
replace text in a file.
<?php
function replace_in_file($FilePath, $OldText, $NewText)
{
$Result = array('status' => 'error', 'message' => '');
if(file_exists($FilePath)===TRUE)
{
if(is_writeable($FilePath))
{
try
{
@ManishLSN
ManishLSN / indiaMap.c
Created August 1, 2017 12:28
make india map by c language code
#include <stdio.h>
int main()
{
int a = 10, b = 0, c = 10;
char* str = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq "
"TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBL"
"OFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm "
"SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
while (a != 0)
{