Skip to content

Instantly share code, notes, and snippets.

View azamanaza's full-sized avatar

Miguel Felipe Calo azamanaza

  • nuskin
  • Philippines
View GitHub Profile
@azamanaza
azamanaza / m2-get-product-image
Created September 12, 2018 05:13
Magento2 - Rendering Product Image
...
@param \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder
@param \Magento\Catalog\Model\Product $product
@param string $imageTypeId (product_base_image | product_page_image_medium)
$imageHtml = $imageBuilder->setProduct($product)
->setImageId($imageId)
->create()->toHtml();
@azamanaza
azamanaza / gist:6ea94b80a07046fa5fff06cfee400f19
Created September 24, 2019 18:41
code to draw a fibo-like spiral
const rangeSum = n => ((n * (n + 1)) / 2) - 1;
const getMaxRange = pxCt => {
let currRange = 2;
while(pxCt > rangeSum(currRange)) {
currRange++;
}
return currRange;
};
@azamanaza
azamanaza / gist:bac1f3fefae384f0d41fcd2520262240
Created November 12, 2019 10:33
Script to check for valid boggle game guesses
const checkWord = (board, word) => {
const boardMap = boardToMap(board);
const startPoints = Array.from(boardMap.values());
if (!startPoints) {
return false;
}
return checkNodes(boardMap, startPoints, [], [], word.split(''), 0);
};
@azamanaza
azamanaza / _cursors.scss
Created October 14, 2020 16:25
A global cursor helper
/*
* Usage
* Just add "cursor-<type>" as class to the element you want to style with a cursor.
*/
$cursors: auto, default, none, context-menu, help, pointer, progress, wait, cell, crosshair, text, vertical-text, alias, copy, move, no-drop, not-allowed, grab, grabbing, all-scroll, col-resize, row-resize, n-resize, e-resize, w-resize, ne-resize, nw-resize, se-resize, sw-resize, ew-resize, ns-resize, nesw-resize, nwse-resize, zoom-in, zoom-out;
@each $cursor in $cursors {
.cursor-#{$cursor} {
cursor: $cursor;
}
@azamanaza
azamanaza / base-model.ts
Last active October 14, 2020 18:13
An extensible base model class
export class BaseModel {
protected properties: string[];
protected relationships: string[] = [];
constructor(data: any, properties: string[], relationships: string[] = []) {
if (!!data) {
Object.keys(data).forEach(key => {
this[key] = data[key];
});
}
@azamanaza
azamanaza / bootstrap.scss
Created November 18, 2020 14:15
Bootstrap gist containing grid, utils and reboot only.
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/grid";
@import "~bootstrap/scss/utilities";
@import "~bootstrap/scss/reboot";
@azamanaza
azamanaza / encapsulate.component.ts
Last active November 19, 2020 18:22
Angular ::ng-deep is set for deprecation. Below is a workaround or a solution until encapsulation is final.
@Component({
selector: 'app-encapsulate',
templateUrl: './encapsulate.component.html',
styleUrls: ['./encapsulate.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class EncapsulateComponent implements OnInit {
constructor(el: ElementRef) {
const { nativeElement } = el;
nativeElement.className = nativeElement.tagName.toLowerCase();