This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TextUtil { | |
public static function sanitize($title) { | |
$replacement = '-'; | |
$map = array(); | |
$quotedReplacement = preg_quote($replacement, '/'); | |
$default = array( | |
'/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ|À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ|å/' => 'a', | |
'/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ|È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ|ë/' => 'e', | |
'/ì|í|ị|ỉ|ĩ|Ì|Í|Ị|Ỉ|Ĩ|î/' => 'i', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function jsonValue() { | |
KEY=$1 | |
num=$2 | |
awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p | |
} | |
KEY_TO_PARSE=$(curl -s -X GET "JSON_URL" | jsonValue KEY_TO_PARSE 1) | |
echo $KEY_TO_PARSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the sample from Scaling PHP applications book | |
#Set the path where the cache is stored; Set the zone name(my_app), totalsize (100m),and max life time(60m) | |
fastcgi_cache_path /tmp/cachelevels=1:2keys_zone=my_app:100minactive=60m; | |
#Set the cache key used,in this case: httpsGETtest.com/somepage.html | |
fastcgi_cache_key "$scheme$request_method$host$request_uri"; | |
server{ | |
listen 80; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Author\PluginName; | |
use System\Classes\PluginBase; | |
use Backend\Facades\BackendMenu; | |
class Plugin extends PluginBase | |
{ | |
public function register() { | |
BackendMenu::registerContextSidenavPartial('Author.PluginName', | |
'sidebar-menu', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Cache; | |
use Cms\Classes\ComponentBase; | |
abstract class CachableComponentBase extends ComponentBase | |
{ | |
/** | |
* Build cache configuration which is an array: ['cachedKey' => 'The cache key value', 'cachedTimeInMinutes' => 'Cached time in minutes'] | |
* @return mixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as AWSXRay from "aws-xray-sdk"; | |
import { logger } from "./logger"; | |
export function trace(name: string) { | |
return (target: any, key: string, descriptor: PropertyDescriptor) => { | |
const originalMethod = descriptor.value; | |
descriptor.value = async function() { | |
let segment: AWSXRay.Subsegment | null = null; | |
try { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* From Effective Java book - 2nd Edition - Author: Joshua Bloch | |
*/ | |
public final class PhoneNumber { | |
private final short areaCode; | |
private final short prefix; | |
private final short lineNumber; | |
public PhoneNumber(int areaCode, int prefix, | |
int lineNumber) { | |
rangeCheck(areaCode, 999, "area code"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --oneline --pretty=format:"%h%x09%an%x09%ad%x09%s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Plugin extends PluginBase | |
{ | |
public function boot() | |
{ | |
parent::boot(); | |
$this->extendRainlabPost(); | |
} | |
protected function extendRainlabPost() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-add ~/.ssh/id_rsa &>/dev/null |
NewerOlder