View data.json
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
{"results":[{"fsq_id":"4c42bf92d691c9b601db8e0a","categories":[{"id":13034,"name":"Café","icon":{"prefix":"https://ss3.4sqi.net/img/categories_v2/food/cafe_","suffix":".png"}}],"chains":[],"distance":202,"geocodes":{"main":{"latitude":52.237009,"longitude":-0.896756}},"link":"/v3/places/4c42bf92d691c9b601db8e0a","location":{"address":"George Row","admin_region":"England","country":"GB","formatted_address":"George Row, Northampton, NN1 1DF","locality":"Northampton","post_town":"Northampton","postcode":"NN1 1DF"},"name":"All Saints Bistro - Northampton","related_places":{"parent":{"fsq_id":"5091102de4b09fc320fc18bb","name":"All Saints Church"}},"timezone":"Europe/London"},{"fsq_id":"57ff893738fa6cf9d0864e65","categories":[{"id":13016,"name":"Lounge","icon":{"prefix":"https://ss3.4sqi.net/img/categories_v2/nightlife/default_","suffix":".png"}},{"id":13034,"name":"Café","icon":{"prefix":"https://ss3.4sqi.net/img/categories_v2/food/cafe_","suffix":".png"}},{"id":13065,"name":"Restaurant","icon":{"prefix":"https:// |
View Makefile
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
# Split all arguments for easier use in commands. | |
# You can now use the variables: ${ARGS} ${ARG_1} ${ARG_2} ${ARG_3} ${ARG_REST} | |
# @see https://stackoverflow.com/questions/2214575/passing-arguments-to-make-run#answer-45003119 | |
ARGS = $(filter-out $@,$(MAKECMDGOALS)) | |
ARG_1 = $(word 1, ${ARGS}) | |
ARG_2 = $(word 2, ${ARGS}) | |
ARG_3 = $(word 3, ${ARGS}) | |
ARG_REST = $(wordlist 2, 100, ${ARGS}) | |
## We use the following rule/recipe to prevent errors messages when passing arguments in make commands | |
## @see https://stackoverflow.com/a/6273809/1826109 |
View test.php
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 | |
$display = \Drupal::entityTypeManager() | |
->getStorage('entity_view_display') | |
->load($param->getEntityTypeId() . '.' . $param->bundle() . '.default'); | |
if ($display && $display->isLayoutBuilderEnabled()) { | |
foreach($display->getSections() as $section) { | |
$result = (bool) array_filter( | |
$section->getComponents(), | |
function (SectionComponent $component) use ($plugin_id) { |
View blob-download.js
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 axios from "axios"; | |
import { saveAs } from "file-saver"; | |
axios(`${apiUrlPrefix}/file/5`, { | |
method: 'GET', | |
responseType: 'blob', | |
headers: { | |
'Authorization': `Bearer ${token}`, | |
} | |
}).then(response => { |
View FrogBuilder.js
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
class FrogBuilder { | |
constructor(name, gender) { | |
// Ensure that the first character is always capitalized | |
this.name = name.charAt(0).toUpperCase() + name.slice(1) | |
this.gender = gender | |
} | |
formatEyesCorrectly(eyes) { | |
return Array.isArray(eyes) ? { left: eye[0], right: eye[1] } : eyes | |
} | |
setEyes(eyes) { |
View gist:7666a0ddebf40f9fff773a61bf9ba92b
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
console.log(performance.memory.usedJSHeapSize) |
View CacheSearch.js
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
/** | |
* Cache class for search. | |
* | |
* Avoid unnecessary api request by caching the results. | |
*/ | |
class CacheSearch { | |
constructor() { | |
this.query = ''; | |
this.queryCount = 0; | |
this.cache = {}; |
View Promise-fetcher.js
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
// Helper method to handle error and expact only error or result. | |
export const createFetcher = promiseFunc => { | |
return { | |
read: arg => { | |
try { | |
return promiseFunc(arg) | |
.then(response => { | |
if (!response) { | |
return {error: 'error!'}; | |
} |
View savings_func.js
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
/** | |
* The script is created purely based the video I saw on youtube about | |
* Personal finance on how to save money with small savings. | |
* | |
* If you invest 2 INR a day,In a year you can save around 133590 INR. | |
* | |
* The calculation goes like if on the 1st of january you save 2 rupees | |
* 2nd january you have to save 2*2 = 4 and 3 day 2*3 = 6 and likewise. | |
* | |
* You can not ideally transac this small amount to the bank, so I created |
View change-month-dropdown.jquery.js
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
// With Jquery. | |
$('.year-select').once('current-year').on('change', function () { | |
var month = $('.month-select'); | |
var currentYear = (new Date()).getFullYear().toString(); | |
var selectedYear = jQuery('.year-select option:selected').val(); | |
if (currentYear === selectedYear) { | |
var currentMonth = (new Date()).getMonth(); |
NewerOlder