My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
This file contains hidden or 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
// See compatibility table for .toBlob() Method | |
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility | |
interface Option { | |
type: 'image/jpeg' | 'image/png' | 'image/webp' | 'image/bmp' | 'image/gif'; | |
quality?: number; | |
} | |
async function compressImage(file: File, option: Option) { | |
if (!file.type.startsWith('image')) { |
This file contains hidden or 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
// INCOMPLETE | |
// This command will give you list of available FFMPEG formats and their default Mime types | |
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)' | |
// And then parse the output with regex to JSON format in JavaScript for example: | |
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n'); | |
// Combine the output with MDN - Common MIME types | |
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types | |
// And with IANA: |
This file contains hidden or 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
<? | |
use Illuminate\Database\Eloquent\Model; | |
class User extends Model | |
{ | |
public function photos() | |
{ | |
return $this->hasMany('\App\Photo'); | |
} | |
public function posts() | |
{ |
This file contains hidden or 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
var cloudinary = require('cloudinary').v2; | |
cloudinary.config({ | |
cloud_name: "<CLOUD NAME>", | |
api_key: "<API KEY>", | |
api_secret: "<API SECRET>" | |
}); | |
var result = []; | |
var options = { type: "upload", max_results: 500, prefix: "<Name of the Folder>/" }; //Add you folder name + `/` |
This file contains hidden or 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 | |
// Add to your (child) theme's functions.php | |
add_filter( 'facetwp_render_params', function( $params ) { | |
foreach ( $params['facets'] as $key => $facet ) { | |
if ( 'keywords' == $facet['facet_name'] ) { // change "keywords" to your actual facet name | |
if ( empty( $facet['selected_values'] ) ) { | |
$params['facets'][ $key ]['selected_values'] = 'circ'; | |
} |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
This file contains hidden or 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
/* Implementation of lodash.get function */ | |
function getProp( object, keys, defaultVal ){ | |
keys = Array.isArray( keys )? keys : keys.split('.'); | |
object = object[keys[0]]; | |
if( object && keys.length>1 ){ | |
return getProp( object, keys.slice(1) ); | |
} | |
return object === undefined? defaultVal : object; | |
} |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
NewerOlder