Skip to content

Instantly share code, notes, and snippets.

@sankarsuda
sankarsuda / cloudSettings
Created November 28, 2018 10:53
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-11-28T10:53:49.513Z","extensionVersion":"v3.2.2"}
@sankarsuda
sankarsuda / ajax-popover.js
Created June 19, 2018 04:19
Boostrap popover with ajax content and auto close on outside click
$(document).on('click', '[data-poload]', function (e) {
var $this = $(this);
//$this.off('hover');
$.get($this.data('poload'), { format: 'html' }, function (d) {
$this.popover({
content: d,
html: true,
placement: 'bottom'
}).popover('show');
});
<?php
class Encryption {
var $skey = "yourSecretKey"; // change this
public function safe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
@sankarsuda
sankarsuda / Psr4AutoloaderClass.php
Created December 6, 2013 04:30
psr autoloader class
<?php
namespace Example;
/**
* An example of a general-purpose implementation that includes the optional
* functionality of allowing multiple base directories for a single namespace
* prefix.
*
* Given a foo-bar package of classes in the file system at the following
@sankarsuda
sankarsuda / download.php
Created December 5, 2013 06:58
function to download file
<?php
function download($fullPath,$ext='')
{
$name = basename($fullPath);
if($ext){
$name = substr($name,0,-4).$ext;
}
@sankarsuda
sankarsuda / header-close.php
Created December 5, 2013 06:55
Close the http connection and run application in background
<?php
/**
* Close the http connection and run application in background
*
* @param string $string string to send in response
* @return void(0)
*/
function headerClose($string = ''){
@sankarsuda
sankarsuda / stream.php
Created December 2, 2013 15:06
Generate and send for download xls files from array
<?php
class streamHelper{
private $mime_types = array(
'.txt' => 'text/plain',
'.json'=> 'application/json',
'.xml' => 'application/xml',
'.doc' => 'application/msword',
'.rtf' => 'application/rtf',
@sankarsuda
sankarsuda / creditcard.php
Last active December 30, 2015 00:39
Generate creditcard numbers for testing
<?php
class creditcardHelper{
public $prefixList = array("4539",
"4556",
"4916",
"4532",
"4929",
"40340071",
"4485",
"4716"
@sankarsuda
sankarsuda / minify.php
Last active December 30, 2015 00:39
Minify and combine css and js files and store in cache
<?php
/*
helper to minify & minimize css and javascript
*/
class minifyHelper{
public $minify = true;
public $defaultOptionsScript = array(
@sankarsuda
sankarsuda / setup.sh
Last active December 29, 2015 19:39
Auto configure Centos for php and node apps
#!/usr/bin/env bash
# Welcome to the server setup script!
#
# install it:
# curl -sL https://gist.github.com/2stech/7718980/raw/setup.sh | sh
#
fancy_echo() {
printf "\n%b\n" "$1"