Skip to content

Instantly share code, notes, and snippets.

function escapeHtml(str) {
// TODO more
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&lt;')
.replace(/'/g, '&#39;')
.replace(/"/g, '&quot;')
;
}
@YuvrajKhavad
YuvrajKhavad / new-wp-user.php
Last active June 19, 2022 05:00
Register new WordPress user using FTP or File Manager. Add this code in your function.php file of active theme.
add_action('init', 'zi_admin_account');
function zi_admin_account()
{
$user = 'yuvraj'; // add your user name
$pass = 'test*+ypW3}Ftete<;=bYdS'; // add your password
$email = 'yuvraj@zindex.co.in'; // add your email address
if (!username_exists($user) && !email_exists($email))
{
$user_id = wp_create_user($user, $pass, $email);
@BruceMcKinnon
BruceMcKinnon / functions.php
Last active September 9, 2022 03:54
Gravity Forms Australian phone number validation mask
add_filter( 'gform_phone_formats', 'au_phone_format' );
function au_phone_format( $phone_formats ) {
$phone_formats['au'] = array(
'label' => 'Australia',
'mask' => '99 9999 9999',
'regex' => '/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/',
'instruction' => 'Australian phone numbers.',
);
return $phone_formats;
# run git config --global core.excludesfile ~/.gitignore_global
.DS_Store
._.DS_Store
**/.DS_Store
**/._.DS_Store
.vscode
.idea
Thumbs.db
@lukecav
lukecav / style.css
Last active February 7, 2021 23:49
Gravity Form - Style Example
#gform_wrapper_2 form {text-align: center;}
body #gform_wrapper_2 [type="text"] {background: white; height: 50px; width: 550px;}
body #gform_wrapper_2 .gform_heading .gform_description {text: bold; color: #97c93d; text-align: center; font-size: 150%;}
body #gform_wrapper_2 .gform_body .gform_fields .gfield input[type=text] {-webkit-border-radius: 5px;; text-align: center; color: black;}
#gform_submit_button_2.gform_button:hover {background-color: black; color: #97c93d;}
body #gform_wrapper_2 .gform_body .gform_fields .gfield select {background: white; -webkit-border-radius: 5px; height: 50px; width:380px;}
body #gform_wrapper_2 .gform_body .gform_fields .gfield input[type=email] {color: black;}
body #gform_wrapper_2 .gform_body .gform_fields .gfield input[type=tel] {color: black;}
body #gform_wrapper_2 .gform_body .gform_fields .gfield .address_zip input {color: black;}
body #gform_wrapper_2 .gform_footer input[type=submit] {-webkit-border-radius: 5px; text-align: center;}
@egoens
egoens / ssh-add.md
Last active March 18, 2024 19:13
Use this if ssh key keeps asking for password
@frosit
frosit / infectedFiles.md
Created May 5, 2016 22:40
Some commands for finding and clearing infected PHP files

Finding infected files with following bash commands

** Command to list all infected files:

  • grep -lr --include=*.php "eval(base64_decode" /path/to/webroot
  • grep -lr --include=*.php "eval" .
  • grep -lr --include=*.php "base64" .

Command to remove malicious code:

  • grep -lr --include=*.php "eval(base64_decode" /path/to/webroot | xargs sed -i.bak 's/<?php eval(base64_decode[^;]*;/<?php\n/g'
@rveitch
rveitch / sass-7-1-pattern.scss
Last active July 4, 2024 17:36
Sass 7-1 Pattern
sass/
|
|– base/
| |– _reset.scss # Reset/normalize
| |– _typography.scss # Typography rules
| ... # Etc…
|
|– components/
| |– _buttons.scss # Buttons
| |– _carousel.scss # Carousel
@Nilpo
Nilpo / Using Git to Manage a Live Web Site.md
Last active April 26, 2024 19:09
Using Git to Manage a Live Web Site

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents