Skip to content

Instantly share code, notes, and snippets.

View Guley's full-sized avatar
🎯
Focusing

Gulshan Guley

🎯
Focusing
View GitHub Profile
@Guley
Guley / update-multiple-columns
Created September 7, 2023 12:04
Update multiple columns in one table based on values in another table in mysql
UPDATE tableA JOIN tabelB USING (id)
SET tableA.column = tabelB.column
@Guley
Guley / remove-duplicates-keep-one
Last active December 4, 2023 07:38
Remove duplicate entries from database a keep only one using MySql
delete table
from table
inner join (
select max(id) as lastId, product_id
from table
group by product_id
having count(*) > 1) duplic on duplic.product_id = table.product_id
where table.id < duplic.lastId;
Generating an SSH key pair
The first step in using SSH authorization with GitHub is to generate your own key pair.
You might already have an SSH key pair on your machine. You can check to see if one exists by moving to your .ssh directory and listing the contents.
$ cd ~/.ssh
$ ls
If you see id_rsa.pub, you already have a key pair and don't need to create a new one.
@Guley
Guley / binary_search_tree.php
Created July 8, 2021 05:10 — forked from meetrajesh/binary_search_tree.php
An efficient binary search tree (BST) implementation in PHP.
<?php
class BinarySearchTree {
private $_root;
public function __construct() {
// setup sentinal node
$this->_root = new BinarySearchNode(null);
}
public function getRoot() {
return $this->hasNode() ? $this->_root->right : null;
@Guley
Guley / client-headers-over-ssl.php
Created March 9, 2020 03:51
Socket ElephantIO header over SSL
<?php
require __DIR__ . '/vendor/autoload.php';
use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version2X;
$options = [
'context' => [
'ssl' => [
<script>
var imagesRef = document.getElementsByTagName('img');
for(var i = 0; i < imagesRef.length; i++) {
var filename = imagesRef[i].src;
var oldAlt = imagesRef[i].alt;
if(oldAlt != null){
var newRa = filename.substring(0, filename.lastIndexOf('.'));
var imgObj = newRa.split("/");
imagesRef[i].alt = imgObj.slice(-1);
}
@Guley
Guley / Read-PDF-JS
Created February 11, 2020 08:04
Get content from file using pdf.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/1.8.349/pdf.min.js"></script>
<button type="button" class="btn btn-default btn-lg tts-btn" title="Upload text, pdf or ebook file">
<span class="glyphicon glyphicon-open-file btn-glyph" aria-hidden="true"></span>
<input type="file" id="files" name="files[]">
</button>
@Guley
Guley / Tcpdf-Watermark
Created January 31, 2020 11:12
Tcpdf add custom text watermark
<?php
require('Pdf.php');
class PDF_Rotate extends Pdf
{
var $angle=0;
function Header()
{
//Put the watermark
$this->SetFont('','B',40);
$this->SetTextColor( 165, 203, 73 );
@Guley
Guley / changeHtdocs
Created January 2, 2020 05:15
Change htdocs location in linux
sudo chown -R $USER /var/www; ln -s /var/www /home/username/htdocs
@Guley
Guley / PHP-Dom-Document-CI
Created November 4, 2019 04:47
Codeigniter Genrate XML Envelope
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class XML extends CI_Controller {
protected $xml;
public function __construct() {
parent::__construct();
$this->xml = new DOMDocument('1.0', 'utf8');
$this->xml->formatOutput = true;