Place this inside any of your templates, or add the main statements to an existing event.
Template.body.onRendered(function () {
// Reading from settings.json
console.log(
Meteor.settings.public.EXISTING_PROPERTY_NAME
);
// Adding a variable/object
Meteor.settings.public.NEW_PROPERTY_NAME = 'PROPERTY-CONTENT';
console.log(
Meteor.settings.public.NEW_PROPERTY_NAME
);
});//rendered
2016-02-27
Meteor - Settings.json split for privacy (client, server or both)
{
"public": {
"PUBLIC-VAR-1": "Available to both CLIENT and SERVER."
, "PUBLIC-VAR-2": "Public var 2 contents."
}
, "private": {
"PRIVATE-VAR-1": "Available to only the SERVER ONLY (not to the client)."
, "PRIVATE-VAR-2": "Private var 1 contents."
}
, "ROOT-LEVEL-VAR-1": "Available to the SERVER ONLY."
, "ROOT-LEVEL-VAR-2": "Root level var 2, only seen by the server."
}
"public": {
"PUBLIC-VAR-1": "Available to both CLIENT and SERVER."
, "PUBLIC-VAR-2": "Public var 2 contents."
}
, "private": {
"PRIVATE-VAR-1": "Available to only the SERVER ONLY (not to the client)."
, "PRIVATE-VAR-2": "Private var 1 contents."
}
, "ROOT-LEVEL-VAR-1": "Available to the SERVER ONLY."
, "ROOT-LEVEL-VAR-2": "Root level var 2, only seen by the server."
}
Meteor - WebStorm Meteor Run settings to use settings.json
This is a screenshot of my environment configuration.
Pass "--settings settings.json" to the "Program argments" textbox of WebStorm's (a JavaScript IDE by JetBrains) run configuration.
Screen-shot:
2016-02-25
Meteor - How to access template parameters and its data context from within an event, programmatically
Template.TEMPLATE-NAME.events({
"click .ELEMENT-CLASS" : function( evt, tmp ){
console.log( tmp.data.PARAMETER-NAME );
console.log( tmp.data.data.FIELD-NAME );
// Output the template's entire data object so you can see what I mean...
console.log(tmp.data); }
});
"click .ELEMENT-CLASS" : function( evt, tmp ){
console.log( tmp.data.PARAMETER-NAME );
console.log( tmp.data.data.FIELD-NAME );
// Output the template's entire data object so you can see what I mean...
console.log(tmp.data); }
});
2016-02-24
VBA - Get a string reversed
' 1. fun_String_Reverse
Public Function fStringReverse(InputString As String) As String
' Declare
Dim lLen As Long, lCtr As Long
Dim sChar As String
Dim sAns As String
' Process
lLen = Len(InputString)
For lCtr = lLen To 1 Step -1
sChar = Mid(InputString, lCtr, 1)
sAns = sAns & sChar
Next
' Return
fStringReverse = sAns
End Function
Public Function fStringReverse(InputString As String) As String
' Declare
Dim lLen As Long, lCtr As Long
Dim sChar As String
Dim sAns As String
' Process
lLen = Len(InputString)
For lCtr = lLen To 1 Step -1
sChar = Mid(InputString, lCtr, 1)
sAns = sAns & sChar
Next
' Return
fStringReverse = sAns
End Function
VBA - Get date/time in different formats (minutes, milliseconds)
Public Function getTimeInMS() As Long
Dim d As Date
d = Now()
Dim t As Single
t = Timer
getTimeInMS = _
( _
(Hour(d) * 10000000#) _
+ (Minute(d) * 100000#) _
+ (Second(d) * 1000#) _
+ fFloor((t - Int(t)) * 1000) _
)
End Function
' Get date in milliseconds
Public Function getDateInMS() As Double
Dim d As Date
d = Now()
Dim t As Single
t = Timer
getDateInMS = _
( _
( _
(Year(d) * 10000000000000#) _
+ (Month(d) * 100000000000#) _
+ (Day(d) * 1000000000#) _
+ (Hour(d) * 10000000#) _
+ (Minute(d) * 100000#) _
+ (Second(d) * 1000#) _
+ fFloor((t - Int(t)) * 1000) _
) _
)
End Function
' Get date in minutes
Public Function getDateInMin() As String
Dim d As Date
d = Now()
Dim t As Single
t = Timer
getDateInMin = _
( _
( _
(Year(d) * 100000000#) _
+ (Month(d) * 1000000#) _
+ (Day(d) * 10000#) _
+ (Hour(d) * 100#) _
+ (Minute(d) * 1#) _
) _
)
End Function
Dim d As Date
d = Now()
Dim t As Single
t = Timer
getTimeInMS = _
( _
(Hour(d) * 10000000#) _
+ (Minute(d) * 100000#) _
+ (Second(d) * 1000#) _
+ fFloor((t - Int(t)) * 1000) _
)
End Function
' Get date in milliseconds
Public Function getDateInMS() As Double
Dim d As Date
d = Now()
Dim t As Single
t = Timer
getDateInMS = _
( _
( _
(Year(d) * 10000000000000#) _
+ (Month(d) * 100000000000#) _
+ (Day(d) * 1000000000#) _
+ (Hour(d) * 10000000#) _
+ (Minute(d) * 100000#) _
+ (Second(d) * 1000#) _
+ fFloor((t - Int(t)) * 1000) _
) _
)
End Function
' Get date in minutes
Public Function getDateInMin() As String
Dim d As Date
d = Now()
Dim t As Single
t = Timer
getDateInMin = _
( _
( _
(Year(d) * 100000000#) _
+ (Month(d) * 1000000#) _
+ (Day(d) * 10000#) _
+ (Hour(d) * 100#) _
+ (Minute(d) * 1#) _
) _
)
End Function
VBA - URL encoding function
Function getUrlEncode(strString) 'As String
' Declare
Dim strUrlEncode
Dim lngPos
' Each character
For lngPos = 1 To Len(strString)
getUrlEncode = _
strUrlEncode & "%" & _
Right( _
"0" & _
Hex(Asc(Mid(strString, lngPos, 1))) _
, 2 _
)
Next
getUrlEncode = strUrlEncode
End Function
' Declare
Dim strUrlEncode
Dim lngPos
' Each character
For lngPos = 1 To Len(strString)
getUrlEncode = _
strUrlEncode & "%" & _
Right( _
"0" & _
Hex(Asc(Mid(strString, lngPos, 1))) _
, 2 _
)
Next
getUrlEncode = strUrlEncode
End Function
Subscribe to:
Posts (Atom)
