Skip to content

Instantly share code, notes, and snippets.

View parasdaryanani's full-sized avatar

Paras Daryanani parasdaryanani

View GitHub Profile
@parasdaryanani
parasdaryanani / formula.xlsx
Created March 2, 2023 08:33
Remove MR MRS DR prefix from Excel
=IF(OR(LEFT(A1,3)="MR ",LEFT(A1,4)="MRS ",LEFT(A1,3)="DR "),RIGHT(A1,LEN(A1)-FIND(" ",A1)),A1)
@parasdaryanani
parasdaryanani / web.config.xml
Created June 14, 2022 08:22
Rewrite /news/t/todays-headlines as /news/todays-headlines
<system.webServer>
<!-- paste the following before the </system.webServer> closing tag -->
<rewrite>
<rules>
<rule name="UsePrettyUrls" stopProcessing="true">
<match url="^news/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
@parasdaryanani
parasdaryanani / findCounty.gs
Last active March 16, 2022 13:34
Get county from postcode
function findCounty(postcode) {
var response = UrlFetchApp.fetch('api.postcodes.io/postcodes/' + postcode);
var resJson = JSON.parse(response.getContentText())
return resJson.result['admin_county'];
}
function findCountyAlt(postcode) {
var response = UrlFetchApp.fetch('api.postcodes.io/postcodes/' + postcode);
var resJson = JSON.parse(response.getContentText())
return resJson.result['primary_care_trust'];
@parasdaryanani
parasdaryanani / calculator.js
Created March 18, 2021 16:32
Calculate profit through chain methods
export default class Calculator {
constructor() {
this.value = 0;
}
revenue(value) {
this.value = value;
return this;
}
@parasdaryanani
parasdaryanani / calculateProfit.js
Last active March 18, 2021 11:28
Calculate Profit using a generic pipe function
const pipe = (...fns) => arg => fns.reduce((value, fn) => fn(value), arg);
const calculateProfit = pipe(
// Deduct EU VAT (0.20)
value => value * (1 - 0.2),
// Deduct corporation tax (0.20)
value => value * (1 - 0.2),
// Add external contributions