Skip to content

Instantly share code, notes, and snippets.

View vishnukumarpv's full-sized avatar

VISHNUKUMAR P V vishnukumarpv

View GitHub Profile
@vishnukumarpv
vishnukumarpv / Validate.php
Created October 26, 2016 08:19 — forked from azrulharis/Validate.php
Php validation using array and display error on each form fields
<?php
class Validate {
public $message = array();
public $validate;
public function rules($data) {
foreach($data as $key => $value) {
@vishnukumarpv
vishnukumarpv / popover.js
Created November 7, 2016 12:29
bootstrap popover with html content
$('h2.prof_name span.admin_s').popover({
html:true,
placement:'right',
content:function(){
// console.log($(this).parent().text());
return $('#qedit--first-last').html();
}
}).on('shown.bs.popover', function () {
var $popup = $(this);
@vishnukumarpv
vishnukumarpv / jQvalidate.html
Last active January 22, 2018 16:04
Declaring jQuery Validate plugin rules inline
<input type="text" name="email" data-rule-required="true" data-rule-email="true">
<input type="text" name="password" id="passoword" data-rule-required="true" data-rule-minlength="6">
<input type="text" name="password-confirm" data-rule-required="true" data-rule-minlength="6" data-rule-equalsto="#password">
<input id="cemail" name="email" data-rule-required="true" data-rule-email="true" data-msg-email="Please enter a valid email address" />
(Tested, core)
@vishnukumarpv
vishnukumarpv / file_extension_to_mimetype.php
Created November 21, 2016 07:51
MIME Types by file extension in a PHP array
$types = array(
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asc' => 'text/plain',
'atom' => 'application/atom+xml',
'atom' => 'application/atom+xml',
'au' => 'audio/basic',
'avi' => 'video/x-msvideo',
@vishnukumarpv
vishnukumarpv / mongoQueries_study.php
Created November 21, 2016 13:25
Mongo DB my queries
public function getAllAppliedJobs( $uid )
{
/*db.getCollection('employer_jobscol').aggregate([
{$match: {"applied_users.user_id": ObjectId("582d99e551d24442857fb6f1") }},
{$unwind: "$applied_users"},
{$match: {"applied_users.user_id": ObjectId("582d99e551d24442857fb6f1") }}
])
*/
$condition = array(
@vishnukumarpv
vishnukumarpv / uploadwithajax.js
Created November 24, 2016 10:10
upload files via ajax
function uploadFiles(event, callback) {
files = event.target.files;
console.log('start');
// event.stopPropagation();
// event.preventDefault();
// START A LOADING SPINNER HERE
console.log('start');
// Create a formdata object and add the files
var data = new FormData();
@vishnukumarpv
vishnukumarpv / Encrypt.php
Created November 24, 2016 11:25
Encrypt and Decrypt with php
<?php
class Encrypt{
private function key( )
{
return $skey = "vishnu_kumar_aUlTIoQaBzk";
}
public function safe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
@vishnukumarpv
vishnukumarpv / handleUpload.php
Created November 25, 2016 09:10 — forked from Abban/handleUpload.php
jQuery AJAX file uploads. Code for the following blog post: http://abandon.ie/notebook/simple-file-uploads-using-jquery-ajax
<?php // You need to add server side validation and better error handling here
$data = array();
if(isset($_GET['files']))
{
$error = false;
$files = array();
$uploaddir = './uploads/';
@vishnukumarpv
vishnukumarpv / phpmailer_helper_live_mail_smtp.php
Last active December 17, 2016 11:27
live (hotmail) smtp for php_mailer
<?php
/**
**
** $mail = new Mail;
** $mail->liveSmtp();
** $mail->template( $templt );
** $mail->send( array( 'to' => 'someone@mail.com' ) );
*/
class Mail
@vishnukumarpv
vishnukumarpv / media-queries.scss
Created January 4, 2017 04:38 — forked from chrisjlee/media-queries.scss
All Media Queries breakpoints
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }