Skip to content

Instantly share code, notes, and snippets.

View angellandros's full-sized avatar

Mohammad-Ali A'râbi angellandros

  • AppTec Services GmbH
  • Freiburg im Breisgau
View GitHub Profile
@angellandros
angellandros / inverted_index.py
Last active June 6, 2018 14:53
Inverted Index on 5-Shingles
from collections import defaultdict
T = {'1' : ' payday', '2' : 'mayday mayday', '3' : 'day may'}
index = defaultdict(set)
# create 5-shingles
for k, v in T.items():
for i in range(len(v) - 4):
index[v[i:i+5]].add(k)
val s = List(1, 2, 3) map (_*2) reduce (_+_)
final int s = ImmutableList.of(1, 2, 3)
.stream()
.map(x -> x * 2)
.reduce(0, (x, y) -> x + y);
@angellandros
angellandros / main.ts
Created October 18, 2019 21:01
Expree.js Hello World
import * as express from 'express';
const app = express();
const port = 3000;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(`Server started listening to port ${port}`));
@angellandros
angellandros / package.json
Last active February 23, 2020 10:32
Node package manager config file for a simple Express.js application
{
"name": "simple-express",
"version": "0.0.1",
"description": "A simple Express.js app",
"main": "src/main.ts",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"typescript": "^3.6.4"
@angellandros
angellandros / tsconfig.json
Created October 18, 2019 21:43
Simple TypeScript config file
{
"compilerOptions": {
"outDir": "../dist",
"baseUrl": "",
"module": "commonjs"
}
}
@angellandros
angellandros / tsoa.json
Last active October 18, 2019 23:47
Sample TSOA config
{
"swagger": {
"basePath": "/api/v1",
"entryFile": "./src/main.ts",
"specVersion": 3,
"outputDirectory": "./api/dist",
"controllerPathGlobs": [
"./src/controllers/**/*controller.ts"
]
},
@angellandros
angellandros / index.controller.ts
Created October 18, 2019 23:38
Sample TSOA controller
import { Controller, Get, Route } from 'tsoa';
@Route('')
export class IndexController extends Controller {
@Get('')
public async index() {
return { msg: 'Hello World!' };
}
@Get('/msg')
@angellandros
angellandros / tsconfig.json
Created October 18, 2019 23:55
Simple TypeScript config with support for decorators
{
"compilerOptions": {
"experimentalDecorators": true, // this line
"outDir": "../dist",
"baseUrl": "",
"module": "commonjs"
}
}
@angellandros
angellandros / main.ts
Created October 19, 2019 00:01
Express.js main files with TSOA generated routes
import * as express from 'express';
import { RegisterRoutes } from './routes/routes'; // here
const app = express();
const port = 3000;
RegisterRoutes(app); // and here
app.listen(port, () => console.log(`Server started listening to port ${port}`));