Tuesday, 3 April 2018

LPD - Low Polyamine Diet

The LPD diet is a hypoallergenic and low polyamine diet, low in putrescine, spermidine, spermine and histamine. Effective for auto-immune conditions. 
Not a money-making scheme - its for relief from pain and misery.
Foods To Eat
FRUIT
Apples
Apricot
Avocado (warning: high histamine)
Blackberries
Black Currant
Blueberries
Coconut
Grapes
Watermelon
Peach

GRAINS/BEANS/SEEDS
Flaxseed
Brown Rice (I cheat & eat basmati white rice!)
Pumpkin Seed

LIQUIDS
FRESHLY juiced veggies 
Tea non-caffeinated. Rooibos.
Water - pure

PROTEIN
Chicken (dark meat only).
Non-processed, non-smoked fish.   Bass, Cod, Herring, Mackerel, Sardines, Salmon, Sole.  Avoid spoilt or old fish. 
Turkey (dark meat) 

SPICES
Black Pepper
Cumin
Ginger
Oregano
Rosemary
Coriander
Quality Salt (Himalayan Pink Salt)
Turmeric

VEGETABLES
Beets – No vinegar.
Artichoke (not Jerusalem Artichokes)
Asparagus
Bok Choy
Brussels Sprouts
Cabbage (Green only)
Carrots
Celery (not much - psoralen & histamine)
Cilantro
Collard Greens
Cucumber
Ginger Root
Green Beans
Kale
Lettuce - not iceberg
Mushrooms (not many)
Onion  (not many)
Basmati Rice - no butter or oil added
Romaine
Sweet Potato (warning: high histamine)
Swiss Chard
Turnips, Parsnips, Swede

Clean eating - FRESH fresh fresh – pick the freshest food on the shelves with the best sell-by date, do not choose pre-cut or sliced-up foods (polyamine rich) , do not choose frozen (polyamine rich) – do not choose slightly gone-off or over ripe foods (polyamine rich)  – remove any parts that looks decayed. Fresh fresh fresh. No canned or processed foods. Shop at fresh food counters. Do not trust restaurants.

Foods NOT to Eat
DAIRY
All dairy

FERMENTED FOODS
Alcohol – especially beer. A little vodka if you must.
Cured Meats
Kimchi
Kombucha
Pickled Vegetables
Sauerkraut
Tofu & Tempeh
Yeast

FRUIT
Banana
Cherry
Dates
Figs
Orange
Mandarin
Tangerine
Grape Fruit
Mango
Melon
Pear
Pineapple
Rasberry
Strawberry

GRAINS/BEANS/LEGUMES
Barley
Buckwheat
Amaranth
Cereals
Corn
Cous-Cous
Gluten
Orzo
Peas
Quinoa (all types)
Wheat
Wheat Flour
Rice (I cheat and eat white basmati rice - seems OK for me)
Soy
Spelt

LIQUIDS –Try to drink pure water only.
Alcohol (a little vodka if you must)
Coffee
Kombucha
Milk Cow
Soy
Almond Milk
Soda
Tea

NUTS & SEEDS – Avoid all nuts and most seeds.
Almonds
Cashews
Hazelnuts
Peanuts
Pistachios
Sesame Seeds
Walnuts
Peanut Butter

PROTEINS
Bacon
Beef
Caviar
Chicken (Breast)
Cured Meat (Jamón Ibérico or Serrano, Pepperoni, Prosciutto, Salami, Ham)
Eggs
Fat
Liver
Pork
Protein Bars
Sausages
Shellfish (Calamari, Crab, Mussel, Oyster, Scallop)

SPICES
Basil
Cayenne, Paprika, Chilli
Parsley
Tarragon
Thyme

VEGETABLES
Artichokes (Jerusalem)
Basil Leaf
Bell Peppers
Cabbage (Red)
Celery (psoralen)
Chickpeas (Garbanzo Beans/Hummus)
Chilli Peppers
Eggplant
Fennel (psoralen)
Goji
Habanero Peppers
Legumes (Nuts, Seeds, Beans, Lentils, Peas and Soy Products)
Lentils
Mushroom
Mustard
Nightshades (tomatoes, potatoes, eggplant, peppers and goji)
Parsley
Pickles
Potatoes
Soy
Spinach
Truffle

MISC. FOODS
Artificial Colouring
Artificial Flavoring
Caffeinated items
Cooking Oils & Fats
Fried Foods
GMO Foods
Ketchup
Malt vinegar
Barbecue sauce
Soy sauce
Thousand Island-type sauces
MSG
Preservatives
Processed Foods
Soy Sauce
Sweeteners: Sugar, Corn Syrup, All Artificial Sweeteners
HFCS High fructose corn syrup

POLYAMINES
Normally polyamines are beneficial for cell regeneration, but in certain skin conditions these polyamines regenerate skin cells faster than normal.   Elevated levels of polyamine proteins (putrescine, spermidine, spermine, histamine) are found in people with auto-immune conditions.

The polyamines putrescine, spermidine and spermine commonly occur in the cells of most organisms. Their participation in human cell growth and proliferation has been of great interest for their role in tumour growth. Histamine is a key factor in inflammatory responses. Polyamines could be useful for post-operation patients, during wound healing and for growth and development of  the neonate digestive system. Both endogenous and dietary polyamines participate in such processes. Data on polyamine contents in  foods are limited and dieticians have thus limited plausible information. This review briefly summarizes  current knowledge on the biological implications of dietary polyamines.


While putrescine content increases by bacterial activity during inappropriate storage and processing  of foods of animal origin, spermidine and spermine originate mainly from raw materials. Higher contents of spermidine as compared  to spermine are typical for foods of plant origin, while an opposite relation is characteristic for foods of animal origin. The highest  contents of all polyamines were determined in cheeses, mainly in ripened types. High putrescine levels were reported in citrus fruits  and juices, sauerkraut, ketchup, fermented soybean products and fish sauce. Legumes, cauliflower and broccoli are foods with high  spermidine content, while meat, meat products and legumes are high in spermine. Commonly, polyamine contents range widely  within the individual food items. Extensive research is needed to extend the current limited database. (Source: 2004 Elsevier Ltd.)


Polyamines are also found in foods which through processing have had the structural integrity of their tissues ‘shocked’ or damaged through food preparation such as quick freezing or canning.


Putrescine Most ‘aged’ or ‘sharp’ cheeses are very high in putrescine. Vegetables such as potatoes, canned/frozen vegetables (other than green vegetables) or certain fruit products, such as oranges and tangerines, can have very high concentrations of putrescine. Fermented soy sauce (containing wheat) is also a rich source of polyamines, particularly putrescine. Shrimp, especially the packaged and frozen types have also been shown to have high levels of putrescine. High amounts are also found in animal foods, citrus fruits, and juices.


Spermidine: Mature cheeses, fermented soybeans, fermented tea, Japanese Sake, domestic mushrooms, broccoli, cauliflower, legumes, soybean, pear (black), potatoes and fresh bread are high sources of spermidine.

Spermine: Cereals (other than bread), canned or frozen vegetables, legumes (seeds and beans), meat products, red meat and poultry (roasted chicken breast) are high sources of spermine.


Histamine – known to cause allergic issues. Fish poisoning – scombroid is thought to be caused by histamines in spoilt fish. Histamine creates inflammation (that's its purpose in the body) but can get out of control. Although this diet sheet is not specifically for histamine it is quite good for achieving low levels (avocado excepted)


The following is a list of polyamine-rich foods to avoid:
Alcohol
Broccoli
Cauliflower
Canned Foods
Cheese (Sharp, Aged / Fermented)
Cereals (Wheat, Corn)
Citrus Fruits (Oranges, Tangerines, Mandarin, Grape Fruit) and Juices
Fermented Foods
Flash Frozen Foods
Ketchup
Legumes (Seeds and Beans)
Lentils
Lunch Meats (e.g. Ham, Turkey, Bologna, and Salami)
Meat (Beef, Roasted Chicken Breast)
Meat Fat
Meat Liver (Chicken)
Meat Ground (Beef, Chicken, Turkey, Pork)
Mushrooms
Mustard
Parsley
Peas
Pear
Potatoes
Processed Foods
Quinoa
Rice Bran
Sauerkraut
Shell Fish
Soybeans Fermented (Tofu, Tempeh)
Spinach
Tomatoes
————
TABLE I
Top 10 foods with the highest polyamine content
(Source: Fred Hutchinson Cancer Research Center)

 ITEM    SERVING SIZE   POLYAMINE (NMOL) PER SERVING SIZE
Putrescine
Corn (fresh/canned) ½ cup 560,000/902,880a
Grapefruit juice 1 cup 276,640
Oranges 1 medium 174,230
Orange juice 1 cup 154,629
Grits 1 cup 99,728
Crab (canned) ½ cup 93,555
Grapefruit ½ medium 90,176
Cream of potato soup 1 cup 70,930
Tortilla chips 1 small bag 56,717
Tomato and V8b juice 1 cup 56,181
Spermidine
Corn (fresh/canned) ½ cup 137,682/221,111a
Green pea soup 1 cup 65,552
Pear 1 medium 60,756
Cheese enchilada 1 medium 48,770
Tempeh 3 oz 42,618
Soy burgers 1 39,616
Peas (fresh/canned) ½ cup 35,9 20/38,165a
Lentil soup 1 cup 37,117
Pasta with meat sauce 1 cup 36,059
Tofu hotdog 1 27,121
Spermine
Green pea soup 1 cup 36,988
Chicken liver 4 oz 33,226
Chili with meat and beans 1 cup 26,441
Chicken breast (grilled/roasted) 1 large 21,560/24,420a
Black bean soup 1 cup 23,786
Peas, fresh 1 medium 23,572
Peas (fresh/canned) ½ cup 20,840/22,143a
Bean with bacon soup 1 cup 22,062
Ground turkey 3 oz 21,535
Tempeh 3 oz 20,565
aThese two figures provide values for the food in the two different forms described.
bCampbell Soup Co, Camden, NJ.
——————
TABLE II
Top 10 major dietary contributors of polyamines
(Source: Fred Hutchinson Cancer Research Center)

ITEM POLYAMINE CONTRIBUTION (NMOL/DAY)
Putrescine
Orange juice and grapefruit juice 44,441
Oranges, grapefruit, and tangerines (not including juice) 17,613
Fresh tomatoes 10,042
Bananas 7,344
Beer (all types) 6,374
Corn and hominy 5,832
Cheese (eg, American, cheddar) 5,592
Potato chips, tortilla chips, corn chips, puffs, and pretzels 4,595
Burritos, tacos, tostadas, and quesadillas 4,411
Green pepper and green chilies 4,343
Spermidine
Green peas 3,283
Cheese, such as American and cheddar 3,124
Lasagna and pasta with meat sauce 2,900
Potatoes (boiled, baked, and mashed) 2,388
Burritos, tacos, tostadas, and quesadillas 1,890
Dark breads (including dark bagels and rolls) 1,736
Green salad (lettuce or spinach) 1,535
Low- or reduced-fat cheese 1,456
Corn and hominy 2,765
Broccoli 1,347
Spermine
Ground meat 2,186
Lunch meats (eg, ham, turkey, bologna, and salami) 1,977
Green peas 1,905
Lasagna and pasta with meat sauce 1,443
Peanut butter, peanuts, and other nuts and seeds 1,237
Rice, noodles, and other grains 1,136
Chili with meat and beans 1,027
Bean soups such as pea, lentil, and black bean 747
Cheese (eg, American, cheddar) 670
Stew, pot pie, and casseroles with meat or chicken 65
Histamine
Alcohol: most notably beer, wine and champagne.
Cooked meat: smoked fish, salami, beef, pork
Raw Meat: shellfish, tuna
Pickled, canned foods: pickles,  relish, soy sauce
Fermented foods such as yogurt, kefir, buttermilk
Cheeses such as parmesan, gouda, swiss, cheddar
Fruit: dried fruit
Vegetables: tomatoes
Legumes: Chickpeas, soybeans, peanuts, and red beans
Beverages: Milk, sodas, sugary beverages
Spices: Cinnamon, chilli powder, nutmeg, curry
Additives: Tartrazine, artificial colors
Preservatives: Benzoates, sulphites, vinegar
Grains: wheat, buckwheat, rye, corn
Foods that facilitate production of histamine in the body: Citrus, papaya, pineapple, nuts, egg whites, food fillers and additives.
Diamine oxidase inhibitors: caffeinated tea

Monday, 2 April 2018

Low Polyamine Diet

The LPD diet is a hypoallergenic and low polyamine diet, low in putrescine, spermidine, spermine and histamine. Effective for auto-immune conditions. 
Not a money-making scheme - its for relief from pain and misery.
Foods To Eat
FRUIT
Apples
Apricot
Avocado (warning: high histamine)
Blackberries
Black Currant
Blueberries
Coconut
Grapes
Watermelon
Peach

GRAINS/BEANS/SEEDS
Flaxseed
Brown Rice (I cheat & eat basmati white rice!)
Pumpkin Seed

LIQUIDS
FRESHLY juiced veggies 
Tea non-caffeinated. Rooibos.
Water - pure

PROTEIN
Chicken (dark meat only).
Non-processed, non-smoked fish.   Bass, Cod, Herring, Mackerel, Sardines, Salmon, Sole.  Avoid spoilt or old fish. 
Turkey (dark meat) 

SPICES
Black Pepper
Cumin
Ginger
Oregano
Rosemary
Coriander
Quality Salt (Himalayan Pink Salt)
Turmeric

VEGETABLES
Beets – No vinegar.
Artichoke (not Jerusalem Artichokes)
Asparagus
Bok Choy
Brussels Sprouts
Cabbage (Green only)
Carrots
Celery (not much - psoralen & histamine)
Cilantro
Collard Greens
Cucumber
Ginger Root
Green Beans
Kale
Lettuce - not iceberg
Mushrooms (not many)
Onion  (not many)
Basmati Rice - no butter or oil added
Romaine
Sweet Potato (warning: high histamine)
Swiss Chard
Turnips, Parsnips, Swede

Clean eating - FRESH fresh fresh – pick the freshest food on the shelves with the best sell-by date, do not choose pre-cut or sliced-up foods (polyamine rich) , do not choose frozen (polyamine rich) – do not choose slightly gone-off or over ripe foods (polyamine rich)  – remove any parts that looks decayed. Fresh fresh fresh. No canned or processed foods. Shop at fresh food counters. Do not trust restaurants.

Foods NOT to Eat
DAIRY
All dairy

FERMENTED FOODS
Alcohol – especially beer. A little vodka if you must.
Cured Meats
Kimchi
Kombucha
Pickled Vegetables
Sauerkraut
Tofu & Tempeh
Yeast

FRUIT
Banana
Cherry
Dates
Figs
Orange
Mandarin
Tangerine
Grape Fruit
Mango
Melon
Pear
Pineapple
Rasberry
Strawberry

GRAINS/BEANS/LEGUMES
Barley
Buckwheat
Amaranth
Cereals
Corn
Cous-Cous
Gluten
Orzo
Peas
Quinoa (all types)
Wheat
Wheat Flour
Rice (I cheat and eat white basmati rice - seems OK for me)
Soy
Spelt

LIQUIDS –Try to drink pure water only.
Alcohol (a little vodka if you must)
Coffee
Kombucha
Milk Cow
Soy
Almond Milk
Soda
Tea

NUTS & SEEDS – Avoid all nuts and most seeds.
Almonds
Cashews
Hazelnuts
Peanuts
Pistachios
Sesame Seeds
Walnuts
Peanut Butter

PROTEINS
Bacon
Beef
Caviar
Chicken (Breast)
Cured Meat (Jamón Ibérico or Serrano, Pepperoni, Prosciutto, Salami, Ham)
Eggs
Fat
Liver
Pork
Protein Bars
Sausages
Shellfish (Calamari, Crab, Mussel, Oyster, Scallop)

SPICES
Basil
Cayenne, Paprika, Chilli
Parsley
Tarragon
Thyme

VEGETABLES
Artichokes (Jerusalem)
Basil Leaf
Bell Peppers
Cabbage (Red)
Celery (psoralen)
Chickpeas (Garbanzo Beans/Hummus)
Chilli Peppers
Eggplant
Fennel (psoralen)
Goji
Habanero Peppers
Legumes (Nuts, Seeds, Beans, Lentils, Peas and Soy Products)
Lentils
Mushroom
Mustard
Nightshades (tomatoes, potatoes, eggplant, peppers and goji)
Parsley
Pickles
Potatoes
Soy
Spinach
Truffle

MISC. FOODS
Artificial Colouring
Artificial Flavoring
Caffeinated items
Cooking Oils & Fats
Fried Foods
GMO Foods
Ketchup
Malt vinegar
Barbecue sauce
Soy sauce
Thousand Island-type sauces
MSG
Preservatives
Processed Foods
Soy Sauce
Sweeteners: Sugar, Corn Syrup, All Artificial Sweeteners
HFCS High fructose corn syrup

POLYAMINES
Normally polyamines are beneficial for cell regeneration, but in certain skin conditions these polyamines regenerate skin cells faster than normal.   Elevated levels of polyamine proteins (putrescine, spermidine, spermine, histamine) are found in people with auto-immune conditions.

The polyamines putrescine, spermidine and spermine commonly occur in the cells of most organisms. Their participation in human cell growth and proliferation has been of great interest for their role in tumour growth. Histamine is a key factor in inflammatory responses. Polyamines could be useful for post-operation patients, during wound healing and for growth and development of  the neonate digestive system. Both endogenous and dietary polyamines participate in such processes. Data on polyamine contents in  foods are limited and dieticians have thus limited plausible information. This review briefly summarizes  current knowledge on the biological implications of dietary polyamines.


While putrescine content increases by bacterial activity during inappropriate storage and processing  of foods of animal origin, spermidine and spermine originate mainly from raw materials. Higher contents of spermidine as compared  to spermine are typical for foods of plant origin, while an opposite relation is characteristic for foods of animal origin. The highest  contents of all polyamines were determined in cheeses, mainly in ripened types. High putrescine levels were reported in citrus fruits  and juices, sauerkraut, ketchup, fermented soybean products and fish sauce. Legumes, cauliflower and broccoli are foods with high  spermidine content, while meat, meat products and legumes are high in spermine. Commonly, polyamine contents range widely  within the individual food items. Extensive research is needed to extend the current limited database. (Source: 2004 Elsevier Ltd.)


Polyamines are also found in foods which through processing have had the structural integrity of their tissues ‘shocked’ or damaged through food preparation such as quick freezing or canning.


Putrescine Most ‘aged’ or ‘sharp’ cheeses are very high in putrescine. Vegetables such as potatoes, canned/frozen vegetables (other than green vegetables) or certain fruit products, such as oranges and tangerines, can have very high concentrations of putrescine. Fermented soy sauce (containing wheat) is also a rich source of polyamines, particularly putrescine. Shrimp, especially the packaged and frozen types have also been shown to have high levels of putrescine. High amounts are also found in animal foods, citrus fruits, and juices.


Spermidine: Mature cheeses, fermented soybeans, fermented tea, Japanese Sake, domestic mushrooms, broccoli, cauliflower, legumes, soybean, pear (black), potatoes and fresh bread are high sources of spermidine.

Spermine: Cereals (other than bread), canned or frozen vegetables, legumes (seeds and beans), meat products, red meat and poultry (roasted chicken breast) are high sources of spermine.


Histamine – known to cause allergic issues. Fish poisoning – scombroid is thought to be caused by histamines in spoilt fish. Histamine creates inflammation (that's its purpose in the body) but can get out of control. Although this diet sheet is not specifically for histamine it is quite good for achieving low levels (avocado excepted)


The following is a list of polyamine-rich foods to avoid:
Alcohol
Broccoli
Cauliflower
Canned Foods
Cheese (Sharp, Aged / Fermented)
Cereals (Wheat, Corn)
Citrus Fruits (Oranges, Tangerines, Mandarin, Grape Fruit) and Juices
Fermented Foods
Flash Frozen Foods
Ketchup
Legumes (Seeds and Beans)
Lentils
Lunch Meats (e.g. Ham, Turkey, Bologna, and Salami)
Meat (Beef, Roasted Chicken Breast)
Meat Fat
Meat Liver (Chicken)
Meat Ground (Beef, Chicken, Turkey, Pork)
Mushrooms
Mustard
Parsley
Peas
Pear
Potatoes
Processed Foods
Quinoa
Rice Bran
Sauerkraut
Shell Fish
Soybeans Fermented (Tofu, Tempeh)
Spinach
Tomatoes
————
TABLE I
Top 10 foods with the highest polyamine content
(Source: Fred Hutchinson Cancer Research Center)

 ITEM    SERVING SIZE   POLYAMINE (NMOL) PER SERVING SIZE
Putrescine
Corn (fresh/canned) ½ cup 560,000/902,880a
Grapefruit juice 1 cup 276,640
Oranges 1 medium 174,230
Orange juice 1 cup 154,629
Grits 1 cup 99,728
Crab (canned) ½ cup 93,555
Grapefruit ½ medium 90,176
Cream of potato soup 1 cup 70,930
Tortilla chips 1 small bag 56,717
Tomato and V8b juice 1 cup 56,181
Spermidine
Corn (fresh/canned) ½ cup 137,682/221,111a
Green pea soup 1 cup 65,552
Pear 1 medium 60,756
Cheese enchilada 1 medium 48,770
Tempeh 3 oz 42,618
Soy burgers 1 39,616
Peas (fresh/canned) ½ cup 35,9 20/38,165a
Lentil soup 1 cup 37,117
Pasta with meat sauce 1 cup 36,059
Tofu hotdog 1 27,121
Spermine
Green pea soup 1 cup 36,988
Chicken liver 4 oz 33,226
Chili with meat and beans 1 cup 26,441
Chicken breast (grilled/roasted) 1 large 21,560/24,420a
Black bean soup 1 cup 23,786
Peas, fresh 1 medium 23,572
Peas (fresh/canned) ½ cup 20,840/22,143a
Bean with bacon soup 1 cup 22,062
Ground turkey 3 oz 21,535
Tempeh 3 oz 20,565
aThese two figures provide values for the food in the two different forms described.
bCampbell Soup Co, Camden, NJ.
——————
TABLE II
Top 10 major dietary contributors of polyamines
(Source: Fred Hutchinson Cancer Research Center)

ITEM POLYAMINE CONTRIBUTION (NMOL/DAY)
Putrescine
Orange juice and grapefruit juice 44,441
Oranges, grapefruit, and tangerines (not including juice) 17,613
Fresh tomatoes 10,042
Bananas 7,344
Beer (all types) 6,374
Corn and hominy 5,832
Cheese (eg, American, cheddar) 5,592
Potato chips, tortilla chips, corn chips, puffs, and pretzels 4,595
Burritos, tacos, tostadas, and quesadillas 4,411
Green pepper and green chilies 4,343
Spermidine
Green peas 3,283
Cheese, such as American and cheddar 3,124
Lasagna and pasta with meat sauce 2,900
Potatoes (boiled, baked, and mashed) 2,388
Burritos, tacos, tostadas, and quesadillas 1,890
Dark breads (including dark bagels and rolls) 1,736
Green salad (lettuce or spinach) 1,535
Low- or reduced-fat cheese 1,456
Corn and hominy 2,765
Broccoli 1,347
Spermine
Ground meat 2,186
Lunch meats (eg, ham, turkey, bologna, and salami) 1,977
Green peas 1,905
Lasagna and pasta with meat sauce 1,443
Peanut butter, peanuts, and other nuts and seeds 1,237
Rice, noodles, and other grains 1,136
Chili with meat and beans 1,027
Bean soups such as pea, lentil, and black bean 747
Cheese (eg, American, cheddar) 670
Stew, pot pie, and casseroles with meat or chicken 65
Histamine
Alcohol: most notably beer, wine and champagne.
Cooked meat: smoked fish, salami, beef, pork
Raw Meat: shellfish, tuna
Pickled, canned foods: pickles,  relish, soy sauce
Fermented foods such as yogurt, kefir, buttermilk
Cheeses such as parmesan, gouda, swiss, cheddar
Fruit: dried fruit
Vegetables: tomatoes
Legumes: Chickpeas, soybeans, peanuts, and red beans
Beverages: Milk, sodas, sugary beverages
Spices: Cinnamon, chilli powder, nutmeg, curry
Additives: Tartrazine, artificial colors
Preservatives: Benzoates, sulphites, vinegar
Grains: wheat, buckwheat, rye, corn
Foods that facilitate production of histamine in the body: Citrus, papaya, pineapple, nuts, egg whites, food fillers and additives.
Diamine oxidase inhibitors: caffeinated tea

Saturday, 16 December 2017

Swift version 4 Search Strings Code examples

Tested in Playground for Xcode 9, Swift Version 4 (4.0.3) tested code samples:

-------------------------------------------------------------------------------------------
Swift 4 Xcode 9: Search for a string in a string with keyword: "contains"

let astring = "Hello dear blog readers, I love this, its is so simple"
let asubstring = "readers, I love"

if astring.lowercased().contains(asubstring.lowercased()) {
    print("the search gave: " + asubstring)

}
// returns the search gave: readers, I love

--------------------------------------------------------------------------------------------
Swift 4 Xcode 9: Search for a string in an Array using "contains" and a filter thing:

let itemsArray = ["Google", "Goodbye", "Go go", "Hello"]
var filterdItemsArray = [String]()
var searchText = "Go go"

filterdItemsArray = itemsArray.filter { item in item.lowercased().contains(searchText.lowercased())}

print(filterdItemsArray)
// returns ["Run away"]


---------------------------------------------------------------------------
Swift 4 Xcode 9: Search for a string in an array using "contains" (but I didn't manage to lowercase it!)



let itemsArray = ["Zebra", "Lion", "Run away", "Leopard"]
var searchText = "Run away"

if itemsArray.contains(searchText) {
    print("the search gave: " + searchText) }

// returns the search gave: Run away


---------------------------------------------------------------------------
Swift 4 Xcode 9: Remove a character from a string using the filter keyword:


let mystring = "blubbery beach"
let filteredString = mystring.filter { $0 != "b" }

print (filteredString)
// returns luery each (takes out the bs from blubbery beach)

---------------------------------------------------------------------------
Swift 4 Xcode 9: String contains example:


print("one two three four".contains("two three"))
// returns: true

---------------------------------------------------------------------------

Swift 4 Xcode 9: Search a string with range of example:

var stringy = "well well, what have we here"

if stringy.lowercased().range(of:"what have") != nil {
    print("exists")

}
// returns: exists

---------------------------------------------------------------------------









Monday, 9 September 2013

Economists main viewpoints all in tiny nutshells

Just to give you an idea of the guys: 

a) Richard Koo 
A balance sheet recession is caused by people who do not want to borrow (because they have been scared by a recent crisis) and would rather pay down their debts than take on new debt. By the Fallacy of Composition this causes a reduction in GDP because nobody is borrowing for growth, leaving a big hole that further depresses economy. The 'solution' is for the government to fill the GDP hole by deficit spending. Uses Japan as main example but applicable for 'once in 70 year crises' for most countries.



b) Joseph Stiglitz

The global export/import balance sheet is zero sum game, so surplus countries (Brazil, China etc) do so at cost of those in deficit (USA etc) The surplus countries keep their surpluses in the global reserve currency - dollars and end up with huge amounts of dollar reserves. The deficit countries try to compensate by creating bubbles that collapse causing crashes and bank failures.
Securitization was a contributory cause of the 2008 crisis caused by lack of data on bad loans implicit in the way securitisation bundles loans in a non-transparent way. 'Asymmetric data' is an error that needs correcting. Also banks benefiting too much from Fed QE because they have access to negative loan rates which are not available to others. The rich are now richer and there has been a loss of living standards for others.
His solution:
1) A global reserve currency bc dollar not able to fulfill that function well.
2) Capital transfer controls to stop financial contagion. He argues using a health analogy that viruses spread via open borders and to stop this health workers try to contain them locally. Should be same for financial 'viruses'.
3) Levy tax on countries in surplus bc they are in surplus at deficit countries cost - they should be taxed
4) Emerging market countries need to increase their home demand more rather than exporting goods abroad - sell them at home more.



c) Paul Krugman
Argues that no matter how much money is created people will not borrow even at the ZIRP and large monetary base because we are in a Keynesian/Fisher style liquidity trap.
He is critised for his supply-demand, Keynsian-like theory that does not account for creation of money in the bank's fractional reserve system.
His solution:
Government deficit spending to increase GDP and we should worry about the increase in debt later when the economy is better or there are new solutions to the debt problem available. Inflation will not happen whilst in a liquidity trap.



d) Cullen Roche
Founder of Pragmatic Capitalism he comments on economic theory and gives investment advice. He predicted the 2007 crisis and now speaks and writes about many economic and investment issues.



e) The Fed
Initially - Provide QE to a) Save banks b) Prevent catastrophic debt defaults b) Improve borrowing (hasn't happened much) c) Write-off non performing loans (MBS) d) Improve stocks and consequently aid growth. + more...
Later - QE resulted in employment figures reaching target of 7% : a) Try forward guidance of 'expected inflation' to improve growth b) Taper QE amounts to prevent excess debt build up
The Fed is continually evolving its policy in line with what it believes is best for employment.



f) IMF
Did a 180 degree turn: At first recommends austerity and paying down debts but later advocated stimulus because 'austerity causes more damage than deficit government spending'.
The IMF was happily promoting the status quo right up to the 2007 credit crisis and continues to blow with the wind of mainstream opinions.



g) BIS
Warned  & predicted 2008 crisis but could not take effective action to prevent it bc not many believed them.
Have written and published various high-level reports and coordinated central bank actions to maintain stabilities. Involved with organising big supra-national currency swaps and other CB actions behind the scenes.
The BIS takes a careful if not negative approach to global economics and produces insightful reports and draws attention to instabilities.



h) ZeroHedge
Points out contradictions, corruption and seeks out and publishes uncomfortable statistics and charts. Often take the view that governments are incompetent and businesses are corrupt and vice-versa.
Often correct and insightful and often plain wrong, but publishes off-the-wall reports and blogs so  'you decide'. (One of my faves - ed)
Have pointed to many reasons for 2008 crisis in their blogs and generally consider QE not effective having creating a false economic recovery based on 'printed money' and over-large government debt.



i) Lord Adair Turner
Reported on the underlying reasons for the credit crisis and uses a selection of relevant economic theory. The main reason is the growth of property related debt that formed a bubble. Says many economic theories are out-of-date because are based on industrial growth being fuelled by industrial  investment. Theories of supply and demand in industry and services is not where most investment is going. Today most investment is towards fixed assets such as property and finance and money creation is via fractional reserve banking and it is this aspect rather than industrial growth problems that  caused the crisis. 



j) Martin Wolf
Well respected journalist at the Financial Times who looks at underlying reasons and causes. The 2007 crisis was caused by a glut of savings coming mainly from China. 
His solution:
Property investment bubble could be solved by taking the money creation ability of the banks and putting it into government hands such as CBs or committees that could direct money creation into more suitable areas. But he realises that this is experimental and may not work in practice : 1) governments would tend to create money for themselves 2) a dangerous shadow banking sector could develop with concomitant systemic instability 
Issues. 3) Government committees may not be the best people to allocate money - central planning route to disaster.



k) Francis Coppola
Blogger and media commentator with expertise in banks and how they operate. Often takes a leftist viewpoint while claiming neutrality, thus subscribes to deficit spending and a more-or-less Keynsian model to provide a strong social services infrastructure.


l) David Beckworth
University guy. Believes in modern monetarist theory as a possible solution & that government can create money, monetise debts - public deficits are good economic management when private sector is struggling. But he also commentates on more orthodox solutions as an economic adviser and commentator on TV.


j) Steve Keen
University guy. Unorthodox economist who disagrees with Fishers Debt Deflation and other mainstream theories. Effects of private debt is a big deal for him.
His solution:
Run public deficits to help economy and "helicopter drop" or OMF consumers to increase demand and assist paying down private debt. USA ran deficit to GDP debt of 15% which, in fact, helped private sector but EZ Mastricht treaty prevented that happening in EZ because debt to GDP is limited to 3% - so EUROPE still in crisis.


k) Noah Smith
Economics blogger active on Twitter and quite famous who picks up fallacies and good points in economic ideas and articles. Says he is a sceptic.









Thursday, 9 August 2012

Robots, tech advances, evolution and economics


Lets construct a thought experiment of a world where 99% of the labour force is unemployed due to advances in digital technology (driverless cars, robots etc etc).

This leaves about 99% (lets assume) capable, reasonable people with no buying power because there is no need for them in the production cycle, thus they have no pay, no money. Hey - they are 'nice' people.

Is there an economic process that works in a practical sense to solve this conundrum?

Yes -or I would not be writing this!

Solutions
In this hypothetical scenario, as I said above, there are no employees in automated factories and since every step is automated there are no production costs (even maintenance, raw materials, mining, farming, delivery etc are all automated). All production is FREE - robots can do it all - nearly.

In this scenario it may appear that production output could be simply given to human consumers? Would not work. This would prevent Adam Smith's invisible hand from inventing new and improving old products - the human consumer would have no feedback to determine the products he/she receives. It would not work well, if at all. Somehow, the consumer needs to feedback desires into the production system. But how? He/she has no money because they are unemployed.

A human consumer must BUY the products and a human producer (owner) must RECEIVE the incomes.
Both of them will then try to maximize their incomes - that's how we rather pathetic critters work - it evolution.

It is the humans that need to drive the creative process because machines do not have desires or 'wants' and thus cannot (as yet) drive the evolutionary processes forward. Desires and wants drive processes on.

Thus its the consumer who has no income that MUST buy products (not simply be given them) - that is the feedback mechanism to human producers who must 'want' money. Its then the good-old win-win situation. The consumer gets to choose the best product and the producer gets the income from the consumers' spending. We know that works with a bit of regulation and law.

But Consumers Have No Money?
Easy - give them money so they can work hard CHOOSING the best products. Not infinite money because then they would not care what they bought. Limited money.

A National Bank uses QE directly to finance consumers, at a fixed annual rate, who then buy products and services.

Inflation would not occur, if carefully implemented, because although the QE increases the money supply, the buying power of consumers would increase real assets proportionately.

You add more details to this theory (I cannot be nbothered to get all the annoying details correct because I AM UNPAID a helloooo).




Friday, 11 May 2012

Google Dart Animation

I have just worked out how to do an HTML 5 animation in the new Dart language and will share the code here.

Dart is similar to JavaScript but is more java-like and appears less illogical than JavaScript.
For example - you have real classes and real objects rather than ... well, whatever those JavaScript entities are - I never did know!
 I am interested in the speed of compiled Dart in a V8 runtime. If its as fast as I believe 9I have seen bench marked as fast as c!!!!) then its the way to go for me.... UPDATE - apparently is NOT particularly fast, damn...... - I will (update, not) be able to render thousands of lovely 3D polygons in my 3D model in a browser - (not) yum. Come on Google - makes it super fast like your Big Table please.

Here is the code for a bouncing ball. Its basically a JavaScript to Dart conversion that I did.
I used Version 0.1.0.201205020515, Build 7232
Dart SDK version 7230, Dartium version in May 2012 (just in case this example is not working any more)

Note: The ball is actually bouncing around - this is a screen shot :)


Just make 2 files and copy paste these two files into Dart IDE, it will work :)
Here is the Dart file (its HTML 5 into Dart type of thing)
********************************************************
#import('dart:html');

class TubeBall {
var x2 = 0;
CanvasElement canvas;  
var ctx;
var x = 400;
var y = 300;
var dx = 2;
var dy = 4;
var WIDTH = 400;
var HEIGHT = 300;
  TubeBall() {
  }
  void circle(x1,y1,r) {
    ctx.beginPath();
    ctx.lineWidth = 5;
    ctx.fillStyle = "blue";
    ctx.strokeStyle = "red";
    ctx.arc(x1, y1, r, 0, Math.PI*2, true);
    ctx.fill();
    ctx.stroke();
  }
  void rect(x3,y2,w,h) {
    ctx.beginPath();
    ctx.rect(x3,y2,w,h);
    ctx.closePath();
    ctx.fill();
    
  }
  void init() {
    write("Hello World!");
    canvas = document.query("#canvas");   
     ctx = canvas.getContext("2d");   
     window.setInterval(draw, 10);
  }
  void clear() {
    ctx.clearRect(0, 0, WIDTH, HEIGHT);
  }
  void draw() {
    clear();
    ctx.fillStyle = "#FAF7F8";
    rect(0,0,WIDTH,HEIGHT);
    ctx.fillStyle = "#444444";
    circle(x, y, 10);
    if (x + dx > WIDTH || x + dx < 0)
      dx = -dx;
    if (y + dy > HEIGHT || y + dy < 0)
      dy = -dy;
    x += dx;
    y += dy;
  }
  void draw3(){
    ctx.beginPath();
    ctx.lineWidth = 5;
    ctx.fillStyle = "blue";
    ctx.strokeStyle = "red";
    ctx.arc(100, 100, 15, 0, 7, false);
    ctx.fill();
    ctx.closePath();
    ctx.stroke();
    x2 += 10;
    ctx.fillRect (30, 30+x2, 55, 50); 
    ctx.fillText("hi ho hum", 300, 300);
    ctx.fillStyle = "#00FF00";
  //  ctx.clientLeft = "100";
    window.setInterval(draw2, 1000);
  }
  void draw2(){
    x += 10;
//    ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
    if(x<80){
    ctx.fillStyle = "#FF0000";
    ctx.fillRect (40+x, 40, 75, 80); 
    } else {
      ctx.fillRect (40, 40+2*x, 75+x, 80);  
      ctx.fillStyle = "#0000FF";
    }

  }  
  void write(String message) {
    // the HTML library defines a global "document" variable

    
    document.query('#status').innerHTML = message;
  }
}

void main() {
  new TubeBall().init();
}
*********************************************************

and here is the html!


**********************************************************

<!DOCTYPE html>

<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>Test</h1>
    <h2 id="status">dart is not running</h2>
    <script type="application/dart" src="TubeBall.dart"></script>
    <script> // dunno what this is..
if (navigator.webkitStartDart) {
  navigator.webkitStartDart();
} else {
  window.addEventListener("DOMContentLoaded", function (e) {

    var scripts = document.getElementsByTagName("script");
    var length = scripts.length;
    for (var i = 0; i < length; ++i) {
      if (scripts[i].type == "application/dart") {
        // Remap foo.dart to foo.js or foo.js_ depending
        // on the chosen compiler (frog or dart2js).
        if (scripts[i].src && scripts[i].src != '') {
          var script = document.createElement('script');
          var compiler = scripts[i].getAttribute('data-compiler');
          if (compiler == "dart2js") {
            script.src = scripts[i].src + '.js_';
          } else {
            script.src = scripts[i].src + '.js';
          }
          var parent = scripts[i].parentNode;
          parent.replaceChild(script, scripts[i]);
        }
      }
    }
  }, false);
}</script>
        <div>
        <canvas id="canvas" width="400" height="300"></canvas>
    </div>
  </body>
</html>




**********************************************************

Hope it works for you  :)

Friday, 30 March 2012

Xcode Image Buttons

Xcode Using No Code in Xcode 4.3 IOS5.1 (as of May 2012)


Image Buttons Zero Code Method


Have you ever had a large image that you want users to be able to click on certain parts of it?
So fo example click on the man with the camera?


You can do that easily in Xcode 4.3 (IOS 5.1) by placing a  button over the area and making it transparent.


Have a look at a youtube video to see exactly how to do it:






Wednesday, 28 March 2012

No Code Xcode

Artists and Creatives - FOR YOU.

At last - make really great iPhone and iPad Apps with absolutely no code!

I have made a series of videos on youtube that explain how to make creative apps using just Storyboard. Not one line of code to be seen. Its all WYSIWYG thanks to Apple's wonderful Xcode IOS 5.1 XCode 4.3 (as of May 2012)

Here are the links:

Xcode for Creatives No Code Image Buttons Tutorial
http://www.youtube.com/watch?v=0fHMMTl00gc

Supplementary Video
http://www.youtube.com/watch?v=cnMlsBBf3D4

iPhone Drill Down App for Non Coders and Creatives Tutorial Xcode
http://www.youtube.com/watch?v=EYm3UH5rQtE

Section Table Cell Display in iPhone No Code Xcode 4.3 IOS 5
http://www.youtube.com/watch?v=DOUNq38uMFM

iPad Adding Table Cell Header Images and Text using No Code
http://www.youtube.com/watch?v=QEjK8j-rJIM

iPhone Xcode 4.3 Table Cell Header Image and Text Tutorial - No Code Method
http://www.youtube.com/watch?v=PCbEkdopcX

Xcode 4.3 for Beginners - What The Buttons Do
http://www.youtube.com/watch?v=Xkqntp_K6Os

Xcode 4.3 Beginners Show Around - The Files
http://www.youtube.com/watch?v=Sg2cH8B6Vpo

Beginners Xcode 4.3 files folders and projects
http://www.youtube.com/watch?v=nmY_00SDhOA



Xcode for Creatives No Code Image Buttons Tutorial
http://www.youtube.com/watch?v=0fHMMTl00gc






iPhone Drill Down App for Non Coders and Creatives Tutorial Xcode





















Friday, 23 March 2012

Cell Sections No Code

Xcode 4.3 IOS 5.1 Cell Sections No Code At All in Storyboard


Great for creative types who hate code - zero zero zero code!


In iPhone and iPad you can make a good app entirely graphically with no code at all.
Here is a picture of one - no code at all!:

Click on a cell and you get this:

Click on the apple cell you get this:

Here is the storyboard: a Navigation Controller (as the starter) linked with a relationship to a TableView Controller. Then 'static' cells (the easy ones!) that are called 'custom' are clicked on to bring up View Controllers connected by a 'push'.


You can watch it free and step by step on youtube:
You need some pictures about 40 pixels square and some photos about 300 by 400 pixels for the big View Controllers. Why not make a little quiz? Or show off your photos?




If you want the source code (its in Xcode 4.3, IOS 5.1)  then here it is:
The source code (£1.01 donation) :
 I will email you back with the source code within 1 day for sure. No catches.