Skip to content

Instantly share code, notes, and snippets.

View felipepodesta's full-sized avatar
👨‍💻
Stairway To Heaven

Felipe Podestá felipepodesta

👨‍💻
Stairway To Heaven
View GitHub Profile
@felipepodesta
felipepodesta / validacao-cf7.php
Created August 3, 2018 05:18
Validação para campos de Data e CPF - Contact Form 7
<?php
/**
* Valida CPF
*
* @author Luiz Otávio Miranda <[email protected]/w>
* @param string $cpf O CPF com ou sem pontos e traço
* @return bool True para CPF correto - False para CPF incorreto
*
*/
@felipepodesta
felipepodesta / panic.php
Created July 31, 2018 04:44 — forked from pounard/panic.php
Drupal panic script (complete)
$_SERVER['HTTP_HOST'] = '127.0.0.1';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
define('DRUPAL_ROOT', getcwd().'/www');
chdir(DRUPAL_ROOT);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/database/database.inc';
require_once DRUPAL_ROOT . '/includes/cache.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
require_once DRUPAL_ROOT . '/includes/module.inc';
require_once DRUPAL_ROOT . '/includes/registry.inc';
@felipepodesta
felipepodesta / lookup-page-example.php
Created July 31, 2018 04:44 — forked from jerbob92/lookup-page-example.php
Creating default pages in Drupal 8
<?php
use Drupal\node\Entity\Node;
$current_language = \Drupal::languageManager()->getCurrentLanguage();
$default_pages = \Drupal::state()->get('my_module.default_pages', array());
$node_id = (isset($default_pages['front_' . $current_language->getId()]) ? $default_pages['front_' . $current_language->getId()] : NULL);
if (!$node_id) {
return NULL;
}
@felipepodesta
felipepodesta / drupal-speed-install.php
Created July 31, 2018 04:43 — forked from pounard/drupal-speed-install.php
Installs a Drupal site really fast (really, really fast) - 3.8 seconds in a standard VM for standard profile
<?php
/**
* @file
* Drupal install speed.
*/
/**
* Yes, this is important.
*/
set_time_limit(0);
@felipepodesta
felipepodesta / d8.php
Created July 31, 2018 04:43 — forked from druman/d8.php
Drupal 8 tweaks
<?php
// thx drupal8.ovh
//// 1) How to get the current language in Drupal 8
//To get the lanuage code:
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
//To get the language name:
$language = \Drupal::languageManager()->getCurrentLanguage()->getName();
@felipepodesta
felipepodesta / README.md
Created June 25, 2018 09:01 — forked from xgvargas/README.md
Gulp -> Coffeescript, SCSS, Jade, SVG to PNG, array(SVG) to SVG

Folder

You are supposed to have this project layout:

node_modules/
bower_components/
coffee/
jade/
scss/

svg/

@felipepodesta
felipepodesta / key-bindings.json
Created June 21, 2018 19:51 — forked from nilium/key-bindings.json
A Sublime Text 2 plugin to enable running multiple commands in any given context from a single key binding.
[
{
"keys": ["ctrl+w"],
"command": "run_multiple",
"args": {
"commands": [
{"command": "find_under_expand", "args": null, "context": "window"},
{"command": "show_panel", "args": {"panel": "find"}, "context": "window"}
]
}
@felipepodesta
felipepodesta / HiddenInput.vue
Created May 24, 2018 13:40 — forked from calebporzio/HiddenInput.vue
Little Vue component for turning JSON into native HTML for inputs
<script>
import _ from 'lodash'
export default {
props: [ 'name', 'value' ],
methods: {
flatInputsFromDeepJson(item, key, h) {
if (typeof item === 'object') {
return _.flatMapDeep(item, (value, newKey) => {
@felipepodesta
felipepodesta / nginx-tuning.md
Created May 2, 2018 19:31 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@felipepodesta
felipepodesta / reset-password.php
Created April 2, 2018 15:32 — forked from gephaest/reset-password.php
Reset password for administrator in Drupal 7
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/password.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
db_query('UPDATE {users} SET pass = :hash WHERE uid = 1',
array(':hash' => user_hash_password('PASSWORD_HERE'))
);