Advertisement
tuomasvaltanen

Untitled

Mar 31st, 2022 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. // pastebin, 31.3.2022
  2.  
  3. const express = require('express')
  4. const app = express()
  5.  
  6. // määritetään portiksi 3000
  7. app.set('PORT', process.env.PORT || 3000)
  8.  
  9. // mitä tehdään kun tähän sivuun navigoidaan nettiselaimella
  10. // tässä tapauksessa palautetaan message-JSON
  11. app.get('/', (req, res) => {
  12. res.status(200).send({
  13. message: 'How do I deploy my code to Heroku using GitLab CI/CD?',
  14. })
  15. })
  16.  
  17. // käynnistetään nodejs-serveri
  18. app.listen(app.get('PORT'), () =>
  19. console.log(`Server running on port ${app.get('PORT')}`),
  20. )
  21.  
  22. module.exports = app;
  23.  
  24. package.json:
  25.  
  26. {
  27. "name": "heroku-gitlab-omaprojekti",
  28. "version": "1.0.0",
  29. "description": "",
  30. "main": "index.js",
  31. "engines": {
  32. "node": "16.14.2",
  33. "npm": "8.5.0"
  34. },
  35. "scripts": {
  36. "start": "node index.js",
  37. "test": "echo \"Error: no test specified\" && exit 1"
  38. },
  39. "repository": {
  40. "type": "git",
  41. "url": "git+https://gitlab.com/OMAPROJEKTIOSOITE"
  42. },
  43. "author": "Tuomas Valtanen",
  44. "license": "ISC",
  45. "bugs": {
  46. "url": "https://gitlab.com/OMAPROJEKTI/issues"
  47. },
  48. "homepage": "https://gitlab.com/tuomasvaltanenLUAS/OMAPROJEKTI#readme",
  49. "dependencies": {
  50. "express": "^4.17.3"
  51. }
  52. }
  53.  
  54. // jos tarvitsee tehdä master branch komentoriviltä, sen voi tehdä näin:
  55.  
  56. git checkout -b staging
  57.  
  58. git checkout -b master
  59. git add .
  60. git commit -a
  61.  
  62. " anna commit-viesti siihen editoriin mikä tulee seille"
  63.  
  64. git push --set-upstream origin master
  65.  
  66. C# :
  67.  
  68.  
  69. public class EventShow
  70. {
  71. /*
  72. Nimi (String)
  73. • Osoite (String)
  74. • Päivämäärä (String tai Date)
  75. • Kategoria (tekstiä, String)
  76. */
  77.  
  78. public string EventName { get; set; }
  79. public string EventAddress { get; set; }
  80. public string EventDate { get; set; }
  81. public string EventCategory { get; set; }
  82.  
  83. public EventShow()
  84. {
  85. EventName = "N/A";
  86. EventAddress = "N/A";
  87. EventDate = "N/A";
  88. EventCategory = "N/A";
  89. }
  90.  
  91. }
  92.  
  93.  
  94. public class EventShowViewModel
  95. {
  96. private ObservableCollection<EventShow> events = new ObservableCollection<EventShow>();
  97.  
  98. // tehdään myös property ylläolevasta muuttujasta
  99. public ObservableCollection<EventShow> Events { get { return this.events; } }
  100.  
  101. public EventShowViewModel()
  102. {
  103. // lisätään yksi testidata listaan
  104. // voi lisätä enemmänkin
  105. this.events.Add(new EventShow()
  106. {
  107. EventName = "Testitapahtuma",
  108. EventAddress = "Testikuja 12",
  109. EventDate = "31.3.2022",
  110. EventCategory = "Koulutus"
  111. });
  112. }
  113. }
  114.  
  115.  
  116.  
  117. try
  118. {
  119. float val1 = float.Parse("123.4");
  120. float val2 = float.Parse("0.0");
  121.  
  122. float sum = val1 / val2;
  123.  
  124. // float palauttaa Infinityn nollalla jakaessa
  125. if (float.IsInfinity(sum))
  126. {
  127. // pakotetaan DivideByZeroException()
  128. throw new DivideByZeroException();
  129. }
  130.  
  131. // asetetaan sum value esim. XAMLiin
  132. // jos yllä oleva if-lause toteutui, tämä skipataan
  133.  
  134.  
  135. }
  136. catch (Exception ex)
  137. {
  138. if (ex is DivideByZeroException)
  139. {
  140. Debug.WriteLine("Ei saa jakaa nollalla!");
  141. }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement