Skip to content

Instantly share code, notes, and snippets.

Avatar

Janith Kasun jkasun

View GitHub Profile
@jkasun
jkasun / index.js
Created Sep 24, 2019
Uploading Files to S3 With Node.js
View index.js
const fs = require('fs');
const AWS = require('aws-sdk');
// Enter copied or downloaded access id and secret here
const ID = '';
const SECRET = '';
// Enter the name of the bucket that you have created here
const BUCKET_NAME = 'test-bucket-1242tsr';;
View person.ts
class Person {
private _age: number;
public set age(age) {
if (age < 0 || age > 200) {
throw new Error('Invalid arguement age');
}
this._age = age;
}
View Person.java
class Person {
private int age;
public int getAge() {
return this.age;
}
public void setAge(int age) {
if (age < 0 || age > 200) {
throw new IllegalArgumentException("Invalid age");
View assignment.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
const int MAXLENGTH = 100; // Max length of the string
int numOfStudents = 2;
int numberOfSubjects = 2;
// Calculate the sum, average of each subject
View angular-host.js
// Get dependencies
const express = require('express');
const path = require('path');
const http = require('http');
const app = express();
// Point static path to dist
app.use(express.static(path.join(__dirname, 'wg-angular')));
View Canvas Line Curve
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
View route.js
let route = () => {
let path = window.location.pathname.split('/');
render(path);
}
let render = (path) => {
let rootPath = path[1];
let template = templates[rootPath];
document.getElementsByTagName('app-root')[0].innerHTML = template;
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<app-root></app-root>
View index.js
const path = require('path');
const express = require('express');
const app = express()
app.use('/public', express.static(__dirname + '/../app/public'));
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname + '/../app/index.html'));
});
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Welcome to Jangular Jumber Jeact</h1>