Skip to content

Instantly share code, notes, and snippets.


Kyriakos Chatzidimitriou kyrcha

View GitHub Profile
kyrcha /
Last active Apr 9, 2021
Basic linux commands without ads

Linux commands


  • change or anything with <...> with the values you want


Create a user


kyrcha /
Created Mar 12, 2021
Remove website from sites-enabled in nginx
  1. cd /etc/nginx/sites-enabled
  2. ls for checking
  3. sudo rm site-to-be-removed
  4. sudo nginx -t, and if OK
  5. sudo service nginx reload
kyrcha /
Last active Mar 11, 2021
Bring a mongodb database from a cloud atlas cluster, locally, using two commands

Let's assume the database is named "production" in your mongodb atlas cluster. First we do a dump:

mongodump --uri="mongodb+srv://<username>:<password>@<subdomain>" --archive="mongodump-production"

Make sure you fill in the correct:

  • username
  • password
  • subdomain
kyrcha /
Last active Jul 7, 2020
Calculate the running average and standard deviation using redis transactions (pipelines in python-redis) and multiple python threads. You can quickly test it by installing a dockerized redis.
from multiprocessing import Pool
import redis
import math
import json
from random import seed
from random import gauss
# Atomic operations
def sum(x):
r = redis.Redis(host='localhost', port=6379, db=0)
kyrcha /
Created Jun 16, 2020
Calculating lines of code for my React+Node projects with cloc
cloc --fullpath --not-match-d='(node_modules|build|static|coverage|__tests__|tests)' --exclude-list-file=notcount .
kyrcha /
Created Jun 10, 2020
Update outdated global npm packages
  1. Check which global packages are outdated with:

npm outdated -g

For example:

  1. Update the pacakges:
kyrcha /
Last active Apr 11, 2020
Confirm your Anaconda ML environment
# Idea from:
# scipy
import scipy
print('scipy: %s' % scipy.__version__)
# numpy
import numpy
print('numpy: %s' % numpy.__version__)
# matplotlib
import matplotlib
kyrcha / websites.controller.ts
Created Mar 31, 2020
Really simple example of a website builder with NestJS, 11ty and nginx - websites.controller.ts
View websites.controller.ts
import { Controller, Post, Body, Get, UseInterceptors, UploadedFile } from '@nestjs/common';
import { CreateWebsiteDto } from './dto/create-website.dto';
import { FileInterceptor } from '@nestjs/platform-express';
import {existsSync, mkdirSync, writeFileSync} from 'fs';
import { randomBytes } from 'crypto';
import { join } from 'path';
import { copySync } from 'fs-extra';
import { exec, pwd } from 'shelljs';
import * as rimraf from 'rimraf';
kyrcha /
Last active Nov 27, 2019
AuthEceSoftEng approach to CodRep-2019 competition

AuthEceSoftEng <> CodRep-2019

The Problem

The goal of the CodRep 2019 competition was to predict formatting errors in source code.

We were given 8000 Java files with one formatting error in each one and another file (out.txt) that contained the character position the formatting error existed. For example, in the snippet below, the error (unnecessary space) is found in position 30:

kyrcha / crawler.js
Last active Nov 26, 2019
npm registry crawler
View crawler.js
var request = require('request'),
cheerio = require('cheerio'),
async = require('async');
var base = '',
concurrency = 2;
var q = async.queue(function(task, next) {
setTimeout(function() {
console.log('GET ' + task.url);