Skip to content

Instantly share code, notes, and snippets.

View changeStringsInFileInCurrentBranch.sh
#!/bin/bash
# $1 - file name
# $2 - string to find
# $3 - string to replace
git filter-branch -f --tree-filter "if [ -f $1 ];then sed -i s/$2/$3/g $1;fi"
View Quick edit wordpress javascript part
(function($) {
// we create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;
// and then we overwrite the function with our own code
inlineEditPost.edit = function( id ) {
// "call" the original WP edit function
// we don't want to leave WordPress hanging
@torian257x
torian257x / app.blade.php
Last active Apr 26, 2021
multi build of laravel mix with performance improvement for tailwindcss "yarn hot" -> javascript as hot, tailwind as watch
View app.blade.php
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
View useRefState useStateWithRef
const useStateWithRef = (initialState) => {
const [state, _setState] = React.useState(initialState);
const ref = React.useRef(state);
const setState = React.useCallback(
(newState) => {
if (typeof newState === 'function') {
_setState(prevState => {
const computedState = newState(prevState);
ref.current = computedState;
return computedState;
View composer.json.example.forpsr4
{
"name": "Myapp/Myapp",
"description": "",
"keywords": ["secret"],
"require": {
"php": ">=5.5.0",
"slim/slim": "3.0",
"slim/php-view": "^2.0",
"monolog/monolog": "^1.17",
"wepay/php-sdk": "^0.2",