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
// Pseudorandom number generator function | |
function getRandomBytes(length) { | |
var result = []; | |
for (var i = 0; i < length; i++) { | |
result.push(Math.floor(Math.random() * 256)); | |
} | |
return result; | |
} | |
// Convert bytes to base62 string |
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
# Clone llama.cpp | |
git clone https://github.com/ggerganov/llama.cpp.git | |
cd llama.cpp | |
# Build it | |
LLAMA_METAL=1 make | |
# Download model | |
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin | |
wget "https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/resolve/main/${MODEL}" |
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
#!/usr/bin/env bash | |
# Same as https://github.com/neovim/neovim/wiki/Installing-Neovim#centos-8--rhel-8 | |
# but requires EPEL 7, not 8. | |
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm | |
yum install -y neovim python3-neovim |
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
/* @theme rk */ | |
@import 'default'; | |
h1, h2, h3 { | |
color: #ffffff; | |
} | |
section { | |
background-image: linear-gradient(to bottom, #67b8e3, #0288d1); |
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 | |
function image_to_base64( $image, $type = 'image/jpeg' ) { | |
// Use new buffer to grab the output. | |
ob_start(); | |
switch ( $type ) { | |
case 'image/jpeg': | |
imagejpeg( $image ); | |
break; |
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 | |
/** | |
* Hook before acf_get_value() queries the DB. | |
*/ | |
add_filter( | |
'acf/pre_load_value', | |
function( $meta, $object_id, $field ) { | |
// Initiate the ACF 'values' store. |
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 | |
/** | |
* This file contains some hooks to improve ACF performance. | |
* | |
* @package rheinardkorf | |
*/ | |
add_filter( | |
'acf/pre_load_value', | |
function( $meta, $post_id, $field ) { |
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
# Get a particular option entry. | |
SELECT * FROM wp_options WHERE option_name="<OPTION_NAME>" LIMIT 1000; | |
# Make sure an option to not autoloaded. | |
UPDATE wp_options SET autoload = 'no' WHERE option_name="<OPTION_NAME>"; | |
# Get the size of total autoladed values. | |
SELECT SUM(LENGTH(option_value)) as autoload_size FROM wp_options WHERE autoload='yes'; | |
# Get the top 10 most "expensive" autoloaded values. |
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 | |
// This example assumes an object cache is available. If its not, transients WITHOUT EXPIRATION will be used. | |
$cache_key = 'unique_prefix_' . md5( $variables ); | |
$results = wp_cache_get( $cache_key ); | |
if ( false === $results ) { | |
$results = $wpdb->get_var( $wpdb->prepare("SQL STATEMENT HERE", $variables['here'], $variables['etc'] )); | |
wp_cache_set( $cache_key, $results ); | |
} |
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
{ | |
"sequence":{ | |
"diagramMarginY" :10, | |
"diagramMarginX" :50, | |
"actorMargin" :50, | |
"width" :150, | |
"height" :65, | |
"boxMargin" :10, | |
"boxTextMargin" :5, | |
"noteMargin" :10, |
NewerOlder