Skip to content

Instantly share code, notes, and snippets.

View Guley's full-sized avatar
🇮🇳
Learning Bot

Gulshan Guley

🇮🇳
Learning Bot
View GitHub Profile
@Guley
Guley / gist:b388229b592758b607d57b32c9ba57c9
Created October 10, 2024 05:56
Setup cron for laravel
php -d register_argc_argv=On /home/directyname/public_html/path/artisan schedule:run > /dev/null 2>&1
@Guley
Guley / skipauth
Created September 27, 2024 09:05
Skip basic auth on htaccess
## .htaccess
### ISPConfig folder protection begin ###
AuthType Basic
AuthName "Members Only"
AuthUserFile /path/.htpasswd
require valid-user
### ISPConfig folder protection end ###
SetEnvIf Request_URI "^/url?quertsting" noauth=1
@Guley
Guley / numbertoword
Created September 4, 2024 11:47
Convert any number to word using php
function numbertoword($number) {
$units = array('', 'One', 'Two', 'Three', 'Four',
'Five', 'Six', 'Seven', 'Eight', 'Nine');
$tens = array('', 'Ten', 'Twenty', 'Thirty', 'Forty',
'Fifty', 'Sixty', 'Seventy', 'Eighty',
'Ninety');
$special = array('Eleven', 'Twelve', 'Thirteen',
'Fourteen', 'Fifteen', 'Sixteen',
@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>