Skip to content

Instantly share code, notes, and snippets.

View fhdalikhan's full-sized avatar
🏠
Working from home

Fahad Ali Khan fhdalikhan

🏠
Working from home
  • Karachi, Pakistan.
View GitHub Profile
@fhdalikhan
fhdalikhan / help
Last active August 9, 2022 15:08
docker solr 4 running instructions
some helpful instructions when I have to change my laptop
clone solr 4 image from https://github.com/fhdalikhan/docker-solr4
on windows don't use git bash, use windows terminal with ubuntu using WSL 2, otherwise will get erros due to line endings being CRLF, which should be LF instead.
build using:
docker build -t solr4 .
run using:
@fhdalikhan
fhdalikhan / gist:b55e7782f29f2e9b49e5e5f45a86f29e
Created January 9, 2022 14:22
recursively change folder ownership by either cron or PHP
# cron example
* * * * * /usr/bin/sudo chown -R GROUP_NAME:USER_NAME /home/fahad/upload_testing/
# php example, needs the user password and user has to have root permissons
system('echo THE_USER_PASSWORD | /usr/bin/sudo -S chown -R GROUP_NAME:USER_NAME /home/fahad/upload_testing/');
@fhdalikhan
fhdalikhan / DQL_example.php
Last active November 11, 2021 09:09
doctrine result set mapping for sql, this will map sql data to entity
<?php
// DQL example, however the result has to be mapped
$entityManager = $this->getEntityManager();
$query = $entityManager->createQuery(
'SELECT nm.id AS nm_id, n FROM \App\Entity\Negotiation n
INNER JOIN n.messages nm WITH nm.id = (SELECT MAX(id) FROM \App\Entity\NegotiationMessage WHERE negotiation_id = n.id)
ORDER BY nm.id DESC'
)->setParameter('direction', EnumMessageDirectionType::TYPE_INBOUND);
@fhdalikhan
fhdalikhan / example.js
Created April 28, 2021 17:13
change browser's back button url
history.pushState(null, null, '<?php echo $_SERVER["REQUEST_URI"]; ?>');
window.addEventListener('popstate', function(event) {
window.location.assign("http://www.yoururl.com/");
});
@fhdalikhan
fhdalikhan / gist:a999bcecefc82ad275686f5cd4140745
Created April 23, 2021 07:10
Solr 4 docker hub and github repo links
solr 4
https://hub.docker.com/r/bxggs/solr4
https://github.com/b-ggs/docker-solr4
https://github.com/docker-solr/docker-solr4
@fhdalikhan
fhdalikhan / gist:6d0a005a521619ad98fa5a815da82964
Last active March 31, 2021 11:49
how to delete all documents from a solr core
# via curl
curl "http://localhost:8983/solr/replaceCoreNameHere/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
# via browser
http://localhost:8983/solr/locationsdirect-products/update?commit=true&stream.body=<delete><query>*:*</query></delete>
@fhdalikhan
fhdalikhan / watch.sh
Last active March 3, 2021 10:09 — forked from espaciomore/watch.sh
Watch command for Git Bash
#!/bin/bash
ARGS="${@}"
clear;
while(true); do
clear
OUTPUT=`$ARGS`
echo -e "${OUTPUT[@]}"
sleep 1
done
@fhdalikhan
fhdalikhan / gist:759043e3bad320912f4bf3734ce74371
Created February 7, 2021 22:23
For SVN command line help
https://www.tutorialspoint.com/svn/svn_review_changes.htm
@fhdalikhan
fhdalikhan / httpd.conf
Created February 2, 2021 12:38
Apache modules to be loaded for zend framework
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule filter_module modules/mod_filter.so
LoadModule version_module modules/mod_version.so
@fhdalikhan
fhdalikhan / copy.php
Created January 28, 2021 18:01
Copy file from another server using PHP
<?php
$file = 'http://domain/all.zip';
$saveFileWithName = "backup.zip";
$newfile = $_SERVER['DOCUMENT_ROOT'] . '/' . $saveFileWithName;
if (copy($file, $newfile)) {
echo "Copy success!";
} else {
echo "Copy failed.";