Skip to content

Instantly share code, notes, and snippets.

gradosevic /
Created May 27, 2021 10:00 — forked from nichtich/
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
gradosevic /
Last active May 27, 2021 08:35

Ignore already added file to .gitignore

git update-index --assume-unchanged file.txt

Remember credentials

git config --global credential.helper store

gradosevic /
Last active October 8, 2021 09:51
Linux commands
#change owner and permissions recursively
sudo chmod -R 775  /ROOT_OF_YOUR_APP/vendor/
sudo chown -R $USER:$USER /ROOT_OF_YOUR_APP/vendor/

#impersonate as www-data in command line
sudo su www-data -s /bin/sh

#Homestead box swithc PHP version
gradosevic /
Last active December 29, 2020 08:40
Laravel Valet use any folder as public

If you've used Valet, you know you have to put your assets in a folder called "public" for it to serve your site or app properly. My host requires that I put my public assets in a folder called "public_html". Some people aren't able to change this without the help of their host. Or maybe you can, but this is much easier!

So, here's the tip.

Use whatever name you want for your public assets folder. (In my case, "public_html"). In Terminal, make sure you are in your project root directory Create a symlink to that folder: ln -s /Your/Path/To/public_html public And you're done! Valet will now see the "public" symlink and serve your site without a hitch.

Hint: You'll probably want to add the new public folder to your .gitignore file

gradosevic / v3_captcha.html
Last active February 8, 2020 13:57
V3 Invisible Captcha
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" />
<script src=""></script>
grecaptcha.ready(function() {
grecaptcha.execute('PUBLIC_KEY', {action: 'homepage'}).then(function(token) {
document.getElementById('g-recaptcha-response').value = token;
gradosevic / wp-setup-checklist.php
Last active March 15, 2019 18:27
WordPress Setup Checklist
//Upload backups script
gradosevic / WPSnippets.php
Last active March 9, 2019 10:17
WP Snippets
//Allow AGCA plugin access only to one person, specified by username
function agca_access_only_admin(){
$screen = get_current_screen();
if($screen->id === 'tools_page_ag-custom-admin/plugin'){
$user = wp_get_current_user();
//Update this ////////////////////
$accessAllowedOnlyTo = 'admin';
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/bin/npm', 'i', '-g', 'npm@latest' ]
2 info using npm@3.10.10
3 info using node@v8.4.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData npm@latest
8 silly fetchNamedPackageData npm
9 silly mapToRegistry name npm
gradosevic / wordpress_add_custom_post_type_column.php
Last active February 27, 2017 16:43
WordPress: custom post type column, create, link and sort by
function manage_mypostype_custom_column( $column, $post_id ) {
global $post;
switch( $column ) {
case 'category':
$terms = get_the_terms( $post_id, 'mypostype-category' );
$theCategory = $terms[0]->name;
gradosevic / wordpress_search_in_custom_fields.php
Last active October 14, 2021 23:18
WordPress: Search in ACF fields, functions.php
/* Join posts and post-meta tables
function cf_search_join( $join ) {
global $wpdb;