Skip to content

Instantly share code, notes, and snippets.

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

Thiago Elias thiagoeliasr

🏠
Working from home
View GitHub Profile
@thiagoeliasr
thiagoeliasr / extractTranslationStrings.php
Created February 8, 2021 18:43 — forked from mariuskubilius/extractTranslationStrings.php
Laravel artisan command to extract translation strings from templates and add them into {language}.json file for localization.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class extractTranslationStrings extends Command
{
# Code below will show the truncate code for all tables in desired schema
SELECT
Concat('TRUNCATE TABLE ', TABLE_NAME, ';')
FROM
INFORMATION_SCHEMA.TABLES
WHERE
table_schema = 'your-table';
# disabling foreign checks for a while
SET FOREIGN_KEY_CHECKS=0;
@thiagoeliasr
thiagoeliasr / remove-node-modules.md
Created August 11, 2019 18:45 — forked from lmcneel/remove-node-modules.md
How to remove node_modules after they have been added to a repo

How to remove node_modules

  1. Create a .gitignore file in the git repository if it does not contain one

touch .gitignore 2. Open up the .gitignore and add the following line to the file

node_modules 3. Remove the node_modules folder from the git repository

@thiagoeliasr
thiagoeliasr / gist:b5979496bf2c3d3d7685c47fcf0489d0
Created July 28, 2019 18:52 — forked from jagregory/gist:710671
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@thiagoeliasr
thiagoeliasr / ApiRequest.php
Last active June 25, 2019 14:25
Validate normal or JSON raw requests in Laravel FormRequest
<?php
class ApiRequest extends FormRequest
{
protected function validationData()
{
return count($this->json()->all()) ? $this->json()->all() : $this->all();
}
}
@thiagoeliasr
thiagoeliasr / delete-all-woocommerce-products.php
Created October 21, 2018 17:49 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@thiagoeliasr
thiagoeliasr / get-string.sh
Created August 8, 2018 19:17
One liner to get all vue-i18n $t strings to translate
echo "export default {" && grep -R '\$t(' resources/assets/js/* | sed "s/^.*(['\"]//g" | sed "s/['\"].*$//g" | sort | uniq | while read -r a; do echo " "\"$a\": \"\"; done && echo "}"
@thiagoeliasr
thiagoeliasr / .bash_profile
Created February 14, 2018 16:03
My OS X simple bash_profile
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
@thiagoeliasr
thiagoeliasr / AndroidOpenExternalSQLite.java
Created October 5, 2017 18:36
Opening sqlite databases using external storage in Android.
/*
Write permission is necessary in your AndroidManifest.xml.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
*/
try {
//Defining your external storage path.
String extStore = Environment.getExternalStorageDirectory().getPath();
//Defining the file to be opened.
File dbfile = new File(extStore + "/yourdatabase.db");
@thiagoeliasr
thiagoeliasr / Tools.php
Created January 16, 2017 18:37
Tools class, to generate Laravel-Format Hash, including Salt and Cost.
<?php
class Tools {
public static function generateLaravelHash($cost, $salt, $pass)
{
return password_hash($pass, PASSWORD_BCRYPT, [
'cost' => $cost,
'salt' => $salt
]);