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
| // ==UserScript== | |
| // @name DVSA finder - This scripts find the slots on or before the specified date/month around a postcode, every 50seconds | |
| // @namespace Script Runner Pro | |
| // @match https://driverpracticaltest.dvsa.gov.uk/manage* | |
| // @grant none | |
| // ==/UserScript== | |
| const MAX_NO_OF_MONTH = 2; // Alert will be triggered when the available month is atleast Feb. | |
| const MAX_DATE = 27; // Example: 27/2 | |
| const TIMEOUT = 50000; // Search will be triggered 50 seconds after the page load. |
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
| // ==UserScript== | |
| // @name Prefill dvsa data - This prefills the form data on the login page and clicks on the login btn | |
| // @namespace Script Runner Pro | |
| // @match https://driverpracticaltest.dvsa.gov.uk/login | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const PROVISIONAL_NO = "GABAXXXXXXXXX"; |
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
| const debounce = (fn, delay) => { | |
| let timer; | |
| return (...args) => { | |
| clearTimeout(timer); | |
| timer = setTimeout(() => { | |
| fn(...args); | |
| }, delay); | |
| } | |
| }; |
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
| const add = (a,b, c) => { | |
| return a + b + c; | |
| } | |
| function curriedFn(fn) { | |
| const argsToCall = []; // [1] | |
| return function returnedFn (...args) { // 1, 2 | |
| argsToCall.push(...args); | |
| if(argsToCall.length < fn.length) { | |
| return returnedFn; |
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
| // Implement array like data structure using objects and proxies in JavaScript. | |
| function CustomArray(...args) { | |
| const proxyobj = { | |
| get length() { | |
| const indices = Object.keys(proxyobj).map(Number).filter(n => !isNaN(n)); | |
| if(indices.length === 0) return 0; | |
| const maxIndex = Math.max(...indices); | |
| return maxIndex + 1; | |
| } |
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
| function fibTCO(n) { | |
| function f(n, va, a) { | |
| if(n === 0) { | |
| return a; | |
| } | |
| return f(n-1, va+a, va); | |
| } | |
| return f(n, 1, 0); | |
| } |
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
| // Callback version of the async task | |
| const someApi = (url, onSuccess, onError) => { | |
| setTimeout(() => { | |
| url === "someURL" ? onSuccess("success") : onError("some error"); | |
| }); | |
| }; | |
| someApi( | |
| "someURL", |
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
| const getCoinsNoV1 = (amount) => { | |
| const coinTypes = [0.25, 0.10, 0.05, 0.01]; | |
| let coinCount = 0; | |
| for (let i = 0; i < coinTypes.length;) { | |
| if (coinTypes[i] <= amount) { | |
| coinCount++; | |
| amount = amount - coinTypes[i]; | |
| } | |
| else { | |
| i++; |
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
| # Usage: | |
| # bash <(curl -L https://gist.githubusercontent.com/rgabs/a6461243956238d9d6255c4bb9a889f5/raw/12fcf6163538cdc35707f87b9ff7a3c2dc62ef59/clean_remote_branches.sh) | |
| # Running the above script will ask the developer for confirmation before deleting any branch. | |
| #!/bin/bash | |
| set -e | |
| GREEN='\033[0;32m'; | |
| RED='\033[0;31m'; |
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
| # This example does the following: | |
| # + Get the latest published version(live version) of react-native-modal-overlay. | |
| # + If the version specified in local package.json is: | |
| # 1. Less than the live version, it runs npm publish command to publish the newer verion. | |
| # 2. Greater or equal than the live version, then it logs a message saying: "Not publishing since version hasn't increased" | |
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # | |
| # Use-case with CI/CD: |
NewerOlder