Skip to content

Instantly share code, notes, and snippets.

@lucymtc
lucymtc / git-rename-branch.txt
Created October 3, 2017 20:17
Rename git branch local & remote
git branch -m old_branch new_branch
git push --set-upstream origin new_branch
git push origin :old_branch
@lucymtc
lucymtc / gist:78306981bce5f04e4b362546b53939e8
Created December 12, 2017 22:32
Creating CA-Signed Certificates for Dev Sites
// Run in the Terminal
-----------------------------------------------
$ openssl genrsa -out mysite.dev.key 2048
$ openssl req -new -key mysite.dev.key -out mysite.dev.csr
-----------------------------------------------
Answer questions after this last command
Then:
Create a mysite.dev.ext
And copy the following.
@lucymtc
lucymtc / gist:db00a275706ed971f82477ed648e4a20
Last active May 18, 2018 09:46
Android emulator network connection with Vagrant IP
cd /Users/lucy/Library/Android/sdk
tools/emulator -avd Nexus_5X_API_23 -writable-system&
prepare file /tmp/hosts with contents:
127.0.0.1 localhost
::1 ip6-localhost
192.168.50.4 politico.test
Then execute:
@lucymtc
lucymtc / react-native-clear-cache.txt
Created May 16, 2018 21:18
React Native clear cache
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start -- --reset-cache
@lucymtc
lucymtc / toUnicode.js
Created July 30, 2018 10:27
JavaScript - String to Unicode
const toUnicode = (str) => {
let unicodeString = '';
for (var i = 0; i < str.length; i ++) {
let unicodeStr = str.charCodeAt(i).toString(16).toUpperCase();
while (unicodeStr.length < 4) {
unicodeStr = `0${unicodeStr}`;
}
@lucymtc
lucymtc / normalizeURL.js
Created July 30, 2018 21:23
JavaScript, URL normalization, make sure HTML entities are escaped.
/**
* URL normalization, make sure HTML entities are escaped.
*
* @param String url
*
* @return String
*/
export function normalizeURL(url) {
const fixedEncodeURIComponent = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16)}`);
@lucymtc
lucymtc / launch.json
Created November 23, 2018 12:16
Visual Studio Code Xdebug config
// Install Extension https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
@lucymtc
lucymtc / gist:7f02527ecd74ffa0408e36c8cf166d7b
Created November 23, 2018 12:34
Favourite Visual Code Extensions
Theme
https://marketplace.visualstudio.com/items?itemName=wesbos.theme-cobalt2
GitLens
https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens
Git History
https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory
PHP Debug
@lucymtc
lucymtc / Encrypt_Decrypt.php
Created December 13, 2018 14:13
Encrypt/Decrypt using WordPress constant SECURE_AUTH_KEY
<?php
// $this->_default_secure_auth_key defined in case SECURE_AUTH_KEY is not defined.
/**
* Encrypt code using OpenSSL
*
* @param string $code The code to encrypt.
*/
public function encrypt_code( $code ) {
if ( empty( $code ) ) {
@lucymtc
lucymtc / gist:a0911b3401d0a3cba778569c4ed8f675
Created February 19, 2019 23:30
Add PHP 5.2 to wp-local-docker v2 ( Mac )
https://github.com/10up/wp-local-docker-v2
Create new environment.
Edit docker-compose.yml
- set phpfpm image: 'liukaitj/php52'
- comment line
# - './config/php-fpm/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'
Run 10updocker stop
Run 10updocker start