Skip to content

Instantly share code, notes, and snippets.

View jagroop's full-sized avatar
👨‍💻
At Office

Jagroop Singh jagroop

👨‍💻
At Office
View GitHub Profile
@jagroop
jagroop / parse_string.php
Last active March 1, 2018 05:40
PHP Parse string and Limit Characters
<?php
function parseString($text, $limit = 100, $end = '')
{
$text = preg_replace("/[\r\n]+/", "\n", $text);
$value = stripslashes(preg_replace("/\s+/", ' ', $text));
if (mb_strlen($value) <= $limit) {
return $value;
}
return rtrim(mb_substr($value, 0, $limit, 'UTF-8')) . $end;
<?php
require 'vendor/autoload.php';
require 'helpers.php';
$randomTxt = "jagroop singh.";
$redeemdesc = 'Reward entitles you to one night of Romance with Giver. Giver will take all necessary steps to create the mood and conditions to spark the';
$redeemPoint = '750';
$title = 'Reward title';
$firstReply = parseString($randomTxt);
$from = 'jagroop';
if (!function_exists('carbon')) {
function carbon(...$args) {
return new Carbon\Carbon(...$args);
}
}
@jagroop
jagroop / test.php
Created March 7, 2018 08:22
sleep time check
public function carbonTest()
{
$tz = 'UTC';
$asia = 'Asia/Calcutta';
date_default_timezone_set($tz);
// $currentTime = carbon()->now()->tz($asia)->format('H:i:s');
$currentTime = '21:01:00';
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Jquery_validation {
private $rules; // json rules for jQuery validator
private $messages; // custom error messages for jQuery validator
private $js_rules = array( 'required' => 'required',
'matches' => 'equalTo',
'min_length' => 'minlength',
'max_length' => 'maxlength',
'greater_than' => 'min',
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class LanguageLoader {
public function initialize() {
$ci =& get_instance();
$ci->load->helper('language');
$siteLang = $ci->session->userdata('site_lang');
if ($siteLang) {
@jagroop
jagroop / moment_js.html
Last active March 19, 2018 10:54
Moment.js Date Time Localization
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing moment Js</title>
</head>
<body>
<table border="1" class="table table-hover" id="myTable">
<thead>
<tr>
<html>
<head>
<title>PaintBrush Application Demo</title>
<style type="text/css">
h1 {
font-size: 20px;
font-weight: bold;
}
@jagroop
jagroop / sdf
Created June 12, 2018 07:39
sf
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["id"]. "</td>
<td>" . $row["name"]."</td>
<td>" . $row["email"]. "</td>
<td><a href='edit.php?id=". $row["id"] ."'> <button class='btn'>Edit</button></a> <br><br>
<a href='formd?id=".$row["id"]."'> <button id='delete-btn' data-user_id='".$row["id"]."''>Delete </button> </a>
</td>
</tr>";
}
echo "</table>";