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
pub fn replace_host<'a>(bytes: &'a str, host_to_replace: &'a str, target_host: &'a str, target_port: u16) -> Cow<'a, str> { | |
let matcher = format!("https?://{}", host_to_replace); | |
Regex::new(&matcher).unwrap().replace_all(bytes, |item: &Captures| main_replace(item, target_host, target_port)) | |
} | |
fn main_replace(caps: &Captures, host: &str, port: u16) -> String { | |
caps.iter().nth(0) | |
.map_or(String::from(""), | |
// here there was a regex match | |
|capture_item| capture_item.map_or(String::from(""), |
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 Graham\FabricSamples\Controller\Order; | |
use Magento\Framework\App\Action\Action; | |
use Magento\Framework\App\ResponseInterface; | |
use Magento\Framework\Controller\ResultFactory; | |
class Form extends Action | |
{ | |
/** |
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 Graham\FabricSamples\Controller\Order; | |
use Magento\Framework\App\Action\Action; | |
use Magento\Framework\App\ResponseInterface; | |
use Magento\Framework\Controller\ResultFactory; | |
class Form extends Action | |
{ | |
/** |
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
/** | |
* Look 👀 - no types anywhere, but still getting the | |
* best type checking Typescript has to offer :) | |
*/ | |
define(['jquery'], function($) { | |
// Typescript knows this is JQuery here so can provide type | |
// safety on all of it's methods | |
console.log($.ajax); |
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 a mapped type I would maintain manually | |
*/ | |
interface DefineTypes { | |
"jquery": JQueryStatic, | |
"underscore": Underscore | |
} | |
/** | |
* This is an example of the 'define' function from requirejs, where it would take |
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 a mapped type I would maintain manually | |
*/ | |
interface DefineTypes { | |
"jquery": JQueryStatic, | |
"underscore": Underscore | |
} | |
/** | |
* This is an example of the 'define' function from requirejs, where it would take |
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
type MyType = El + serde::Serialize; | |
fn debug<MyType>(field: &MyType) { | |
match serde_json::to_string(field) { | |
Ok(j) => { | |
let text_area = TextArea { | |
name: "output".into(), | |
value: j.into() | |
}; | |
form_builder::document.body().append_child(text_area.build()); |
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 | |
/** | |
* Menu template | |
* | |
* @var $block \Ves\Megamenu\Block\Menu | |
*/ | |
?> | |
<?php | |
if ($menu = $this->getMenu()) { | |
$html = $classes = ''; |
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
<div class="subnav__col"><a class="subnav__title subnav__title--underling-01" href="{{config path="web/secure/base_url"}}furniture">Furniture</a> | |
<ul class="subnav__list subnav__list--featured"> | |
<li class="subnav__item nav-2-1"><a class="subnav__link" href="{{config path="web/secure/base_url"}}furniture/view-all-furniture">View All</a></li> | |
<li class="subnav__item nav-2-2"><a class="subnav__link" href="{{config path="web/secure/base_url"}}furniture/new-in-furniture">New In</a></li> | |
<li class="subnav__item nav-2-3"><a class="subnav__link subnav__link--divider" href="{{config path="web/secure/base_url"}}furniture/bestsellers-furniture">Bestsellers</a></li> | |
<li class="subnav__item nav-2-4"><a class="subnav__link" href="{{config path="web/secure/base_url"}}furniture/bone-inlay">Bone Inlay Collection</a></li> | |
<li class="subnav__item nav-2-5"><a class="subnav__link" href="{{config path="web/secure/base_url"}}furniture/mother-of-pearl">Mother of Pearl Collection</a></li> | |
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 'interface' | |
trait Callable { | |
fn step(&self) -> Result<(), String>; | |
fn rollback(&self) -> Result<(), String>; | |
} | |
// this is an enum that's constrained to only | |
// structs that implement 'Callable' | |
#[derive(Debug)] | |
enum Task<T: Callable> { |