Skip to content

Instantly share code, notes, and snippets.

@gradosevic
gradosevic / README.md
Created May 27, 2021 — forked from nichtich/README.md
How to automatically deploy from GitHub
View README.md

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)
View GIT.md

Ignore already added file to .gitignore

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

Remember credentials

git config --global credential.helper store

@gradosevic
gradosevic / LINUX.md
Last active Oct 8, 2021
Linux commands
View LINUX.md
#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
gradosevic / laravel-valet-use-public-folder-with-any-name.md
Last active Dec 29, 2020
Laravel Valet use any folder as public
View laravel-valet-use-public-folder-with-any-name.md

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
gradosevic / v3_captcha.html
Last active Feb 8, 2020
V3 Invisible Captcha
View v3_captcha.html
<form>
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" />
<script src="https://www.google.com/recaptcha/api.js?render=PUBLIC_KEY"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('PUBLIC_KEY', {action: 'homepage'}).then(function(token) {
document.getElementById('g-recaptcha-response').value = token;
});
});
@gradosevic
gradosevic / wp-setup-checklist.php
Last active Mar 15, 2019
WordPress Setup Checklist
View wp-setup-checklist.php
<?php
//Links
//https://www.codeinwp.com/blog/secure-your-wordpress-website/
//Upload backups script
//https://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line/
/////////////////////////////
View WPSnippets.php
<?php
//Allow AGCA plugin access only to one person, specified by username
function agca_access_only_admin(){
if(is_admin()){
$screen = get_current_screen();
if($screen->id === 'tools_page_ag-custom-admin/plugin'){
$user = wp_get_current_user();
//Update this ////////////////////
$accessAllowedOnlyTo = 'admin';
View npm debug log
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
gradosevic / wordpress_add_custom_post_type_column.php
Last active Feb 27, 2017
WordPress: custom post type column, create, link and sort by
View wordpress_add_custom_post_type_column.php
<?php
function manage_mypostype_custom_column( $column, $post_id ) {
global $post;
switch( $column ) {
case 'category':
$terms = get_the_terms( $post_id, 'mypostype-category' );
if($terms[0]){
$theCategory = $terms[0]->name;
@gradosevic
gradosevic / wordpress_search_in_custom_fields.php
Last active Oct 14, 2021
WordPress: Search in ACF fields, functions.php
View wordpress_search_in_custom_fields.php
<?php
///////////////////////////////////
/// SUPPORT FOR SEARCHING IN ACF
///////////////////////////////////
/* Join posts and post-meta tables
*
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
*/
function cf_search_join( $join ) {
global $wpdb;