Skip to content

Instantly share code, notes, and snippets.

@PunGy
Last active February 4, 2025 09:19
Show Gist options
  • Save PunGy/d5583a47d12d9422da33565829e75f51 to your computer and use it in GitHub Desktop.
Save PunGy/d5583a47d12d9422da33565829e75f51 to your computer and use it in GitHub Desktop.
const table = [{"name":"1 Pair of Jeans (Levis 501 Or Similar)","category":"Clothing And Shoes","cost_of_living_factor":0.35,"rent_factor":0},{"name":"1 Summer Dress in a Chain Store (Zara, H&M, ...)","category":"Clothing And Shoes","cost_of_living_factor":0.35,"rent_factor":0},{"name":"1 Pair of Nike Running Shoes (Mid-Range)","category":"Clothing And Shoes","cost_of_living_factor":0.35,"rent_factor":0},{"name":"1 Pair of Men Leather Business Shoes","category":"Clothing And Shoes","cost_of_living_factor":0.35,"rent_factor":0},{"name":"Milk (regular), (1 liter)","category":"Markets","cost_of_living_factor":25,"rent_factor":0},{"name":"Loaf of Fresh White Bread (500g)","category":"Markets","cost_of_living_factor":31,"rent_factor":0},{"name":"Rice (white), (1kg)","category":"Markets","cost_of_living_factor":14,"rent_factor":0},{"name":"Eggs (regular) (12)","category":"Markets","cost_of_living_factor":20,"rent_factor":0},{"name":"Local Cheese (1kg)","category":"Markets","cost_of_living_factor":12,"rent_factor":0},{"name":"Chicken Breasts (Boneless, Skinless), (1kg)","category":"Markets","cost_of_living_factor":15,"rent_factor":0},{"name":"Beef Round (1kg) (or Equivalent Back Leg Red Meat)","category":"Markets","cost_of_living_factor":15,"rent_factor":0},{"name":"Apples (1kg)","category":"Markets","cost_of_living_factor":31,"rent_factor":0},{"name":"Banana (1kg)","category":"Markets","cost_of_living_factor":25,"rent_factor":0},{"name":"Oranges (1kg)","category":"Markets","cost_of_living_factor":30,"rent_factor":0},{"name":"Tomato (1kg)","category":"Markets","cost_of_living_factor":22,"rent_factor":0},{"name":"Potato (1kg)","category":"Markets","cost_of_living_factor":24,"rent_factor":0},{"name":"Onion (1kg)","category":"Markets","cost_of_living_factor":10,"rent_factor":0},{"name":"Lettuce (1 head)","category":"Markets","cost_of_living_factor":18,"rent_factor":0},{"name":"Water (1.5 liter bottle)","category":"Markets","cost_of_living_factor":30,"rent_factor":0},{"name":"Bottle of Wine (Mid-Range)","category":"Markets","cost_of_living_factor":4,"rent_factor":0},{"name":"Domestic Beer (0.5 liter bottle)","category":"Markets","cost_of_living_factor":6,"rent_factor":0},{"name":"Imported Beer (0.33 liter bottle)","category":"Markets","cost_of_living_factor":6,"rent_factor":0},{"name":"Cigarettes 20 Pack (Marlboro)","category":"Markets","cost_of_living_factor":15,"rent_factor":0},{"name":"Apartment (1 bedroom) in City Centre","category":"Rent Per Month","cost_of_living_factor":0,"rent_factor":0.25},{"name":"Apartment (1 bedroom) Outside of Centre","category":"Rent Per Month","cost_of_living_factor":0,"rent_factor":0.25},{"name":"Apartment (3 bedrooms) in City Centre","category":"Rent Per Month","cost_of_living_factor":0,"rent_factor":0.25},{"name":"Apartment (3 bedrooms) Outside of Centre","category":"Rent Per Month","cost_of_living_factor":0,"rent_factor":0.25},{"name":"Meal, Inexpensive Restaurant","category":"Restaurants","cost_of_living_factor":16,"rent_factor":0},{"name":"Meal for 2 People, Mid-range Restaurant, Three-course","category":"Restaurants","cost_of_living_factor":3.5,"rent_factor":0},{"name":"McMeal at McDonalds (or Equivalent Combo Meal)","category":"Restaurants","cost_of_living_factor":6,"rent_factor":0},{"name":"Domestic Beer (0.5 liter draught)","category":"Restaurants","cost_of_living_factor":5,"rent_factor":0},{"name":"Imported Beer (0.33 liter bottle)","category":"Restaurants","cost_of_living_factor":5,"rent_factor":0},{"name":"Cappuccino (regular)","category":"Restaurants","cost_of_living_factor":15,"rent_factor":0},{"name":"Coke/Pepsi (0.33 liter bottle)","category":"Restaurants","cost_of_living_factor":6,"rent_factor":0},{"name":"Water (0.33 liter bottle)","category":"Restaurants","cost_of_living_factor":6,"rent_factor":0},{"name":"Fitness Club, Monthly Fee for 1 Adult","category":"Sports And Leisure","cost_of_living_factor":2.3,"rent_factor":0},{"name":"Tennis Court Rent (1 Hour on Weekend)","category":"Sports And Leisure","cost_of_living_factor":3,"rent_factor":0},{"name":"Cinema, International Release, 1 Seat","category":"Sports And Leisure","cost_of_living_factor":6,"rent_factor":0},{"name":"One-way Ticket (Local Transport)","category":"Transportation","cost_of_living_factor":20,"rent_factor":0},{"name":"Monthly Pass (Regular Price)","category":"Transportation","cost_of_living_factor":1.5,"rent_factor":0},{"name":"Taxi Start (Normal Tariff)","category":"Transportation","cost_of_living_factor":5,"rent_factor":0},{"name":"Taxi 1km (Normal Tariff)","category":"Transportation","cost_of_living_factor":20,"rent_factor":0},{"name":"Taxi 1hour Waiting (Normal Tariff)","category":"Transportation","cost_of_living_factor":0.7,"rent_factor":0},{"name":"Gasoline (1 liter)","category":"Transportation","cost_of_living_factor":60,"rent_factor":0},{"name":"Volkswagen Golf 1.4 90 KW Trendline (Or Equivalent New Car)","category":"Transportation","cost_of_living_factor":0.0035,"rent_factor":0},{"name":"Toyota Corolla 1.6l 97kW Comfort (Or Equivalent New Car)","category":"Transportation","cost_of_living_factor":0.0035,"rent_factor":0},{"name":"Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment","category":"Utilities (Monthly)","cost_of_living_factor":1,"rent_factor":0},{"name":"1 min. of Prepaid Mobile Tariff Local (No Discounts or Plans)","category":"Utilities (Monthly)","cost_of_living_factor":320,"rent_factor":0},{"name":"Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)","category":"Utilities (Monthly)","cost_of_living_factor":1,"rent_factor":0}]
// 04/02/2025
const NYC_prices = {"Meal, Inexpensive Restaurant":30,"Meal for 2 People, Mid-range Restaurant, Three-course":132.5,"McMeal at McDonalds (or Equivalent Combo Meal)":12,"Domestic Beer (0.5 liter draught)":9,"Imported Beer (0.33 liter bottle)":3.72,"Cappuccino (regular)":5.86,"Coke/Pepsi (0.33 liter bottle)":3.21,"Water (0.33 liter bottle)":2.49,"Milk (regular), (1 liter)":1.56,"Loaf of Fresh White Bread (500g)":4.97,"Rice (white), (1kg)":7.87,"Eggs (regular) (12)":5.48,"Local Cheese (1kg)":17.75,"Chicken Fillets (1kg)":15.6,"Beef Round (1kg) (or Equivalent Back Leg Red Meat)":19.93,"Apples (1kg)":7.61,"Banana (1kg)":2.48,"Oranges (1kg)":6.22,"Tomato (1kg)":6.57,"Potato (1kg)":3.96,"Onion (1kg)":3.76,"Lettuce (1 head)":3.1,"Water (1.5 liter bottle)":2.52,"Bottle of Wine (Mid-Range)":20,"Domestic Beer (0.5 liter bottle)":2.89,"Cigarettes 20 Pack (Marlboro)":18,"One-way Ticket (Local Transport)":2.9,"Monthly Pass (Regular Price)":132,"Taxi Start (Normal Tariff)":5,"Taxi 1km (Normal Tariff)":2.17,"Taxi 1hour Waiting (Normal Tariff)":39,"Gasoline (1 liter)":1.01,"Volkswagen Golf 1.4 90 KW Trendline (Or Equivalent New Car)":33000,"Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)":28123.63,"Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment":176.74,"Mobile Phone Monthly Plan with Calls and 10GB+ Data":65.77,"Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)":65.06,"Fitness Club, Monthly Fee for 1 Adult":158.43,"Tennis Court Rent (1 Hour on Weekend)":72.22,"Cinema, International Release, 1 Seat":20,"Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child":3122.44,"International Primary School, Yearly for 1 Child":59000,"1 Pair of Jeans (Levis 501 Or Similar)":67.81,"1 Summer Dress in a Chain Store (Zara, H&M, ...)":46.47,"1 Pair of Nike Running Shoes (Mid-Range)":112.32,"1 Pair of Men Leather Business Shoes":170.18,"Apartment (1 bedroom) in City Centre":3982.55,"Apartment (1 bedroom) Outside of Centre":2913.17,"Apartment (3 bedrooms) in City Centre":8576.79,"Apartment (3 bedrooms) Outside of Centre":5288.18,"Price per Square Meter to Buy Apartment in City Centre":17953.77,"Price per Square Meter to Buy Apartment Outside of Centre":12887.36,"Average Monthly Net Salary (After Tax)":5612.52,"Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate":6.6}
const tableElem = document.querySelector("table.data_wide_table > tbody")
const prices = Array.prototype.filter.call(tableElem.children, (t) => t.children[1].className.includes('priceValue'))
.reduce((acc, elem) => {
const { children: [ title, price ] } = elem
acc[title.textContent.trim()] = parseFloat(price.textContent.trim().replace(',', ''))
return acc
}, {})
Object.entries(NYC_prices).reduce(
(sum, [name, price]) => {
const factor = table.find(t => t.name === name)
if (factor) {
return price * (factor.cost_of_living_factor + factor.rent_factor)
}
return sum
}, 0
)
const BasketConsumerPlusRent = (prices) => (
Object.entries(prices).reduce(
(sum, [name, price]) => {
const factor = table.find(t => t.name === name)
if (factor) {
return sum + (price * (factor.cost_of_living_factor + factor.rent_factor))
}
return sum
}, 0
)
)
const purchasingPower = (salary, prices) => (
(salary / BasketConsumerPlusRent(prices)) / (NYC_prices["Average Monthly Net Salary (After Tax)"] / BasketConsumerPlusRent(NYC_prices))
)
const calc = (salary) => purchasingPower(salary, prices) * 100
// Put here your salary after taxes and recieve your purchasing power index
calc(1000)
@InvisibleHawk
Copy link

This looks like monkey code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment