List of public pages created with Protopage

Main

News

World - BBC

BBC News | England | UK Edition

Business

Technology

Guardian Unlimited

The Age - Latest News

TechCrunch

House Prices

The Economist feed 1

The Economist feed 2

Lifehack

Brexit

Wired News - Top Stories

AUD

Bookmarks

Projects

Maintain

Quick Links

TimeWaste

Bookmarks

Work

Videos

Reading

Reference Links

Web widgets

Prediction Markets

Start

Bookmarks

Histmaps

Physics

Arts

Philiosophy

Geography

Self Help

Maths

MilHistory

3d studio

Chaps

General

QFT

Films

Writing

Cool Links

Music

Politics

Plain sticky notes

Ideas

Meditation Power half hour yoga Excercise

Todo lists

Todo list

http://en.wikipedia.org/wiki/Split-octonion
Processing.org examples

Photos

BI

Plain sticky notes

Plan

- Put forward ideas - Understand Contexts - V - Review simple DAX functions - Download Carlos Power BI

Rich sticky notes

Functions

Row Filter Context

CALCULATE  -  Replaces row context with filter context.

CurrRate = CALCULATE(Sum(Table[a]))
 (so sum() on a column(a) in a new column would give a total of (a), however Calculate(sum(a)) would apply a filtercontext for the calculation, and filter out all the rows except the one current row, so it would give you the values of a.  

Filter cuts out the rows with specific date condition, Max finds maximum rate of the filtered subset. 
Replaces row context with filter context.
Note - whenever you add a measure an automatic hidden 'calculate' is added in the express. Hence a measure should not have a table name.
Link




SumX(Table, Expression) - allows expressions within the sum, ie algebra, filters, if statements. Apposed to Sum table which calculate the sum of a column





CROSSFILTER - The function returns no value; the function only sets the cross-filtering direction for the indicated relationship, for the duration of the query.

CROSSFILTER(<columnName1>, <columnName2>, <direction>)



ALL
Sometimes you are stuck in the filter context due tot the CALCULATE function, this may pin you down to a more specific context than you want. However ALL lets you jump out of this context. 

SalesYTD - CALCULATE ([SalesAmount], FILTER (
ALL('Date'), Date[Date]>1-jan-2019)
You require the ALL because inside CALCULATE in the calculation the dates will be limited to the filter context.


Concepts

Filter Context - set of filters that gets applied before a table arrives for use. 

Row Context - When you add a row to a table, row context lets a rows calculation look at other values in the same row.
Link

Iterators 
MaxX, MinX, AverageX, SumX, etc. Iterates over a table column.Use calculate to turn the row context into a filter context. 


Debugging Measures - 
To debug a measure, always ask what is the current filter context of the calculation. Sometimes the issues with a measure is that you need to correct the filter context by adding calculate to the statement within the measure. 



CALCULATE makes the filter context more specific, ALL makes it broader. 

Podcasts

News

Best of Today feed 1

Best of Today feed 2

Best of Today feed 3

Drama/Comedy of the Week feed 1

Drama/Comedy of the Week feed 2

Drama/Comedy of the Week feed 3

WNYC's Radiolab feed 1

WNYC's Radiolab feed 2

WNYC's Radiolab feed 3

WNYC's Radiolab feed 4

World Weekly with Gideon Rachman feed 1

World Weekly with Gideon Rachman feed 2

World Weekly with Gideon Rachman feed 3

Front Row Daily feed 1

Front Row Daily feed 2

Front Row Daily feed 3

From Our Own Correspondent

WTPS feed 1

WTPS feed 2

Peter Day's World of Business

National Public Radio

Is Free Will an Illusion? What Can Cognitive Science Tell Us? - YouTube

Freakonomics Radio

Analysis/File on 4 feed 1

Analysis/File on 4 feed 2

Analysis/File on 4 feed 3

Analysis/File on 4 feed 4

Analysis/File on 4 feed 5

In Our Time With Melvyn Bragg

BBC Discovery

Last Word

On The Money feed 1

On The Money feed 2

On The Money feed 3

Inheritance Tracks feed 1

Inheritance Tracks feed 2

Inheritance Tracks feed 3

Bookclub

NPR Topics: Technology Podcast

Weekend Catchup feed 1

Weekend Catchup feed 2

The Listening Project

Voices of VR Podcast – Designing for Virtual Reality

Click

Profile

To The Point

GreshamCollege

Science Friday Audio Podcast

Lives in a Landscape

Bookmarks

Music Station

Audio Books

Bookmarks

Bookmarks

Bookmarks

Podcast 2

News

NPR Programs: Fresh Air Podcast

Feedback

Germany: Memories of a Nation

Documentary of the Week

Philosopher’s Arms

Desert Island Discs with Kirsty Young

Tales from the Ringroad

A History of Ideas

Law in Action

NeuroPod

All TWiT Shows (MP3)

The Economist: Full edition

HOW TO DO EVERYTHING

Podcasts 3

News

Point of Inquiry

HARDtalk

Documentaries

A History of the World in 100 Objects

Great Lives

Reith Lectures Archive: 1976-2011

China: As History is My Witness

Reith Lectures Archive: 1948-1975

Excel

Rich sticky notes

Excel Reference

Combining Text and a date in the same cell

="Date:  "&TEXT(F1,"dd/mm/yy")

 

=(Load*interest)/(1-(1+interest)^-(periods))

Https//

= Load Items:



Using the Frequency Function

http://www.youtube.com/watch?v=jbaXnT5CX18 




3d St

Bookmarks

Changes to Husky PDS

SDK

Add Log to Video

Notes

Bookmarks

VB Class

Rich sticky notes

Main - ref Agent Class

Public Type Scape
Sugar As Single
Spice As Integer
End Type

Public Grid(1 To 30, 1 To 30) As Scape

Public id As Integer

Public AllAgents As New Collection 'collection of objects object
Public Agn As Agent 'used within the class, hence public

Public Const gridsize = 30


Sub MainCycle()

 Columns("A:A").Select
    Selection.ClearContents
    Range("A1").Select
   

   Set Agn = New Agent ' creates the first agent
  
      AllAgents.Add Agn
      Agn.Name = "Bob"
      Agn.x = 25
      Agn.y = 25
      Agn.Sugar = 100
      Agn.Spice = 100
      Agn.Generation = 1
      'AgnNew.AAge = 1
  
   n = 1
  
   For i = 1 To 20000 'number of iterations
      Harvest 'calls harvest procedure 
      DisplayGrid 
     

      id = 1
      For Each Agn In AllAgents
         Agn.LookAndMove 
         Agn.Eat 
         Agn.Appear 
         Agn.Breed 
         id = Agn.Die(id)

'this is an example of the function in use. Note it is defeined as a 'function' and the reference to die = something. Note when agent dies, function returns id -1, hence when deleted from the AllAgents collection the next agent in the list will have the die function called, and not skipped over.
      
      id = id + 1
      Next Agn
      Worksheets("Sheet2").Cells(n, 1).Value = AllAgents.Count ' collections object build in procedure count
      n = n + 1
   Worksheets("Sheet2").Cells(1, 1).Activate ' refreshed the graph sheet
   Next

   ' Although the following two lines aren't
   ' necessary, they're a good idea.
  
   Set Agn = Nothing
   Set AllAgents = Nothing

End Sub


Sub DisplayGrid()

   For i = 1 To gridsize
      For j = 1 To gridsize
        
         If Grid(i, j).Sugar > 0 And Grid(i, j).Spice > 0 Then
            Worksheets("Sheet1").Cells(i, j).Interior.ColorIndex = 38 ' spice & sugar
         End If
        
         If Grid(i, j).Sugar = 0 And Grid(i, j).Spice = 0 Then
            Worksheets("Sheet1").Cells(i, j).Interior.ColorIndex = xlNone 'nothing
         End If
        
         If Grid(i, j).Sugar = 0 And Grid(i, j).Spice > 0 Then
            Worksheets("Sheet1").Cells(i, j).Interior.ColorIndex = 40 ' spice
         End If
        
         If Grid(i, j).Sugar > 0 And Grid(i, j).Spice = 0 Then
            Worksheets("Sheet1").Cells(i, j).Interior.ColorIndex = 34 'sugar
         End If
        
      Next
   Next

End Sub


Sub Harvest()
   For i = 1 To gridsize
      For j = 1 To gridsize
        
         If Int(Rnd * 20) + 1 = 1 Then
            Grid(i, j).Sugar = Grid(i, j).Sugar + 7
            Grid(i, j).Spice = Grid(i, j).Spice + 7
         End If
      Next
   Next

End Sub

Agent Class Module

Private Ax, Ay As Integer
Private ASugar, ASpice As Single
Private AName As String
Private AGeneration As Integer
Private AAge As Integer


Public Property Get Name() As String
    Name = AName
End Property
Public Property Let Name(Value As String)
    AName = Value
End Property


Public Property Get x() As Integer
    x = Ax
End Property
Public Property Let x(Value As Integer)
    Ax = Value
End Property


Public Property Get y() As Integer
    y = Ay
End Property
Public Property Let y(Value As Integer)
    Ay = Value
End Property


Public Property Get Sugar() As Single
    Sugar = ASugar
End Property
Public Property Let Sugar(Value As Single)
    ASugar = Value
End Property


Public Property Get Spice() As Single
    Spice = ASpice
End Property
Public Property Let Spice(Value As Single)
    ASpice = Value
End Property


Public Property Get Generation() As Integer
    Generation = AGeneration
End Property
Public Property Let Generation(Value As Integer)
    AGeneration = Value
End Property


Public Sub LookAndMove()

   Dim h As Integer
   Dim direction As String
   h = 0
  
   If x = 1 Then x = 2
   If x = gridsize Then x = gridsize - 1
   If y = 1 Then y = 2
   If y = gridsize Then y = gridsize - 1
  
   If Grid(x - 1, y).Sugar + Grid(x - 1, y).Sugar > h Then
      h = Grid(x - 1, y).Sugar + Grid(x - 1, y).Sugar
      direction = "Right"
   End If
  
   If Grid(x + 1, y).Sugar + Grid(x + 1, y).Sugar > h Then
      h = Grid(x + 1, y).Sugar + Grid(x + 1, y).Sugar
      direction = "Left"
   End If
  
   If Grid(x, y - 1).Sugar + Grid(x, y - 1).Sugar > h Then
      h = Grid(x, y - 1).Sugar + Grid(x, y - 1).Sugar
      direction = "Down"
   End If
  
   If Grid(x, y + 1).Sugar + Grid(x, y + 1).Sugar > h Then
      h = Grid(x, y + 1).Sugar + Grid(x, y + 1).Sugar
      direction = "Up"
   End If


   Select Case direction
  
      Case Is = "Right"
         x = x - 1
      Case Is = "Left"
         x = x + 1
      Case Is = "Down"
         y = y - 1
      Case Is = "Up"
         y = y + 1
      Case Else
         x = x + Int(Rnd * 3) - 1
         y = y + Int(Rnd * 3) - 1
   End Select

End Sub


Public Sub Appear()
Worksheets("Sheet1").Cells(x, y).Interior.ColorIndex = 5
End Sub


Public Sub Eat()
Dim a As String

   ASugar = Grid(x, y).Sugar + ASugar
   Grid(x, y).Sugar = 0
  
   ASpice = Grid(x, y).Spice + ASpice
   Grid(x, y).Spice = 0
  
   ASpice = ASpice - 5
   ASugar = ASugar - 5
  
End Sub


Public Sub Breed()
   If ASugar > 100 And ASpice > 100 Then
   
     
Dim AgnNew As Agent 
      Set AgnNew = New Agent ' creates new agent
      
          AllAgents.Add AgnNew ' procedure adds AgnNew to the AllAgents collection
            AgnNew.Name = "Bob." & AGeneration + 1
            AgnNew.x = Ax
            AgnNew.y = Ay
            AgnNew.Sugar = Int(ASugar / 2)
            AgnNew.Spice = Int(ASpice / 2)
            AgnNew.Generation = AGeneration + 1

         ASugar = Int(ASugar / 2)
         ASpice = Int(ASpice / 2)
   End If
  

End Sub


Public Function Die(id As Integer) ' Note Function returens the id - 1 back to where it's called

   If ASpice < 0 Or ASugar < 0 Then
      AllAgents.Remove (id) 'deletes id-th from the AllAgents List
      Die = id - 1
   Else
      Die = id
   End If


End Function

VB Ref

Bookmarks

Bookmarks

Plain sticky notes

VBA

Worksheets("Sheet2").Cells(y, x).Value = 0 char = Right(Left(string, i), 1)

Rich sticky notes

Code Basics

Definitions

 

Dim x as Integer      'define local variable

Public p as Single    'define global variable

 

Public Type Scape   'define type
Sugar As Single
Spice As Integer
End Type

 

Scape.Sugar = 0.5   'can apply to a

 

Const Maximum = 100 'creates a constant that can be refered to during runtime


Code Structure

 

If p >= 5 then

' Statement - p is over 5

Else If p < 5 and p > 2

'Statement - p is inbetween 5 and 2

Else If p <= 2 and  p > 1

'Statement - p is inbetween 2 and 1

Else If p <= 2 and  p > 1

'Statement - p is less than 1

Else

'Statement all other cases

End If


p = 1 ' standard do until loop structure

Do Until p >10

p = p + 1

Loop


For x = 1 To 10 Step 2 ' standard for structure with (optional) step 2

p = x + p

Next


Select Case direction '(better use If, Else If, Else If.... Else, End If)
     
Case
100 to 200, "dog", 37
         x = x - 1
     
Case Is
= "Left"
         x = x + 1
     
Case Is
= "Down"
         y = y - 1
     
Case Is
= "Up"
         y = y + 1
     
Case Else
         x = x + Int(Rnd * 3) - 1
         y = y + Int(Rnd * 3) - 1
End Select


Arrays

 

Public Grid(1 to 50, 1 to 50 ) as integer 'define array, can be n dimensional

 

UBound(code) ' function returns the upper size of the array UBound(array,[dimension])

 

for i = 0 to UBound(Arr)

'Statements

Next

 

ReDim Preserve array(10, 10, 15) 'allows you to chage the dimesnions of a existing array


Specifics

Worksheets("info").CheckBox1.Value


Application.ScreenUpdating = False 
Application.Calculation = xlCalculationManual

Application.ScreenUpdating = True

Application.Calculation = xlCalculationAutomatic


If Worksheets("Matrix").CheckBoxes("Check Box 7") = xlOn Then 'if cost


Set w = Worksheets("info")


Worksheets("Sheet2").Cells(y, x).Value = 0

Worksheets("Sheet1").Cells(y, x).Interior.ColorIndex = xlNone 'numbers


Int(Rnd * 20) + 1 ' Returns random number between 1 and 20



On Error GoTo Error1:

'Statemetns 

Error1:


me.   'references the object the code is being written in, sheets, classes etc


For Each Workbook In Worksheets 'cycles workbooks in the worksheets object collection

Next


Worksheets("TimeSeries").Cells(y, x).FormulaR1C1 = "=SUM(R[" & n & "]C:R[-1]C)"

'Syntex for inserting variables inside written statement in cell formula


Goto Lastline ' jumps to last part of programme

Lastline:


ActiveChart.SeriesCollection(1).XValues = "=ChartData!R1C3:R1C" & GraphED & ""

'inserting variable in output formula.

ActiveChart.SeriesCollection(3).XValues = "=ChartData!R1C" & GraphDD & ":R1C" & GraphED & ""


'Inserting varibles inside

SlippageValue = Replace(SlippageValue, " d", "")  'Removes letter d


DoEvents ' allows control objects to be edited during runtime!!


Exit For ' jumps out of the loop (save time)

Exit Do

Exit Sub

Examples

'Example of looping through text field and splitting

   Des = Worksheets("Main").Cells(r, RDescription).Value
  
   MainDes = ""
   SubDes = ""
   Tag = False
   For i = 1 To Len(Des)
      c = Right(Left(Des, i), 1)
     
      If c = "." Then
         Tag = True
      End If
     
      If Tag = False Then
         MainDes = MainDes + c
     
Else
         SubDes = SubDes + c
      End If
   Next

Examlpe return funciton (byVal)

Public Function IsHolorWknd(ByVal d As Date) As Boolean ' Note Function returens the id - 1 back to where it's called
'note the use of ByVal as opposed to the defail ByVal, ByRef is the variable itself (hence the 'reference' to the data, ByVal is a copy of the variable

 

Passing Argument by Value or by Reference

If you pass an argument by reference when calling a procedure, the procedure access to the actual variable in memory.  As a result, the variable's value can be changed by the procedure.

Note this allows you to change more than one variable within a function, because calling by reference changes the values of the addressed variables.

So

function F(byref x, byref y)
x=x-1
y=y-1
F=x+y
end sub

 


y = 2
Do Until Worksheets("Hols").Cells(y, 1).Value = Empty

   IsHolorWknd = False
  
   If Worksheets("Hols").Cells(y, 1).Value = d Then 'loops through hols sheets 
      IsHolorWknd = True
      GoTo Found
   End If

y = y + 1
Loop
  
Found:

End Function

Msgbox

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to continue ?"    ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2    ' Define buttons.
Title = "MsgBox Demonstration"    ' Define title.
Help = "DEMO.HLP"    ' Define Help file.
Ctxt = 1000    ' Define topic,         ' context. ' display message.
      
Response = MsgBox(Msg, Style, Title, Help, Ctxt)


If Response = vbYes Then    ' User chose Yes.
    MyString = "Yes"    ' Perform some action.
Else    ' User chose No.
    MyString = "No"    ' Perform some action.
End If

 

Useful / Interesting

    'Trys error
On Error Resume Next
    N = 1 / 0    ' cause an error
    If Err.Number <> 0 Then
        N = 1
    End If
   

Example of Function

Sub main()

temp = complex(1, 1)

End Sub


Function complex(a, b As Single) As Single

at = a
bt = b

For t = 1 To 30

   Re1 = a * at
   Im1 = a * bt
   Im2 = b * at
   Re2 = -b * bt
  
   at = Re1 + Re2
   bt = Im1 + Im2

Next

complex = Sqr(at ^ 2 + bt ^ 2)

End Function

Photos

VB Examples

Rich sticky notes

Attraction By Ref

Sub AttractExample()
y1 = 1
x1 = 1

y2 = 100
x2 = 100

Call AttractGen(y1, x1, y2, x2)

 

End Sub


'--------------------------------------------------------

'attracts co-ordinates

Function AttractGen(ByRef y1, x1, y2, x2) ' note no variable declaration

dy = y1 - y2
dx = x1 - x2

 

If dx + Abs(dx) = 0 Then neg = -1 Else neg = 1
d = Sqr(dx ^ 2 + dy ^ 2)
a = -(d ^ 0.5)

If dx <> 0 Then
Theta = Atn(dy / dx)
End If

ay = neg * a * Sin(Theta)
ax = neg * a * Cos(Theta)

y1 = y1 + ay
x1 = x1 + ax

y2 = y2 - ay
x2 = x2 - ax


End Function

Photos

Code

Bookmarks

Bookmarks

Python

Processing

Rich sticky notes

Example code

x = y = z = 0  # Zero x, y and z

 

Complext Numbers

(1+2j)/(1+1j)

a.real

a.imag

abs(a)  # sqrt(a.real**2 + a.imag**2), (2**2 = 4)

QFT Videos

Bookmarks

DrPhysicsA

Bookmarks

Notice Board

Plain sticky notes

Sticky note

91212 896 3096 - 22096 159753 Google: High level, with low level

Photos

Level of effort

.Interior.ColorIndex

Work

Bookmarks

Links

ReadlingList

News

xkcd.com

Bookmarks

Bookmarks

GramSpell

Rich sticky notes

Grammer

Affect "to influence," - "The rain affected Amy's hairdo."  

Effect ”a result" - "The rain had no effect on Amy's hairdo."


“Gems that sparkle often elicit forgiveness”. The words that sparkle restrict the kind of gems you're talking about. So you it’s a that

There was an earthquake in China, which is bad news.

Can throw out the “whiches”