Skip to content

Instantly share code, notes, and snippets.

@kvn1234
kvn1234 / www.conf.txt
Created June 21, 2017 18:10
Random file or log locking in Laravel 5 on Homestead with nginx
sudo vi /etc/php/7.1/fpm/pool.d/www.conf
comment out last two lines
add
user = vagrant
group = vagrant
write/quit
sudo service php7.1-fpm restart
sudo service nginx restart
COMPOSER_CACHE_DIR=/tmp/foo composer update
@kvn1234
kvn1234 / config_name.conf
Last active June 26, 2017 00:05
Create logrotater - linux
**** create file: sudo vi /etc/logrotate.d/descriptive_name_here
**** code example, e.g., this one is symfony:
/var/www/current/var/logs/prod.log {
su ubuntu www-data
create 0664 ubuntu www-data
daily
missingok
rotate 14
compress
@kvn1234
kvn1234 / laravel_seed_from_migration
Created June 26, 2017 00:14
How to add a seed after migration
***new migrations might need seeds in laravel. If you try to run "php artisan migrate --seed", artisan will choke on it.
***the solution is to call the seeder from the migration:
public function up()
{
//schema changes here
//now the data migration
Artisan::call('db:seed', [
'--class' => MigrationSpecificSeeder::class,
]);
@kvn1234
kvn1234 / gist:ac808016001c9a8e2d6a9c080e18afde
Created August 4, 2017 17:45
mod_pagespeed cache flushing
touch `grep "^ *ModPagespeedFileCachePath" /etc/apache2/mods-enabled/pagespeed.conf | awk ' { print $2; } ' | sed 's/"//g'`/cache.flush
or
touch `grep "^ *ModPagespeedFileCachePath" /etc/httpd/conf.d/pagespeed.conf | awk ' { print $2; } ' | sed 's/"//g'`/cache.flush
@kvn1234
kvn1234 / increment_build_number.js
Last active October 27, 2017 16:58
Ionic & Cordova hook for incrementing build & version numbers
#!/usr/bin/env node
// Save hook under `project-root/hooks/before_prepare/`
//
// Don't forget to install xml2js using npm
// `$ npm install xml2js`
// tested with Cordova 7.0.1 & Ionic 3.7.0
var fs = require('fs');
var xml2js = require('xml2js');
@kvn1234
kvn1234 / theme.zsh-theme
Created August 16, 2017 21:45
custom oh-my-zsh theme
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='%{$fg_bold[blue]%}$USER@%M %{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@kvn1234
kvn1234 / git.txt
Created August 27, 2017 17:19
Git commands I always forget
git update-index --assume-unchanged <file-path>
@kvn1234
kvn1234 / regex.txt
Created January 16, 2018 15:36
PHP Regex for finding a URL path
(href=")([A-Za-z0-9_\.\/-]*)(") (no http or https://)
(href=")([\:A-Za-z0-9_\.\/-]*)(") (any url string in an href)
@kvn1234
kvn1234 / database_size_txt
Created January 16, 2018 19:53
Get size of mysql databases
SELECT table_schema 'database',
Round(Sum(data_length + index_length) / 1024 / 1024, 1)
FROM information_schema.tables
GROUP BY table_schema;