Skip to content

Instantly share code, notes, and snippets.

import org.junit.Assert.assertEquals
import org.junit.Test
class Wrapper {
companion object {
fun wrap(s: String, lineSize: Int): String {
var formattedString = ""
formattedString += if (s.length > lineSize) s.substring(0, lineSize) + "\n" + wrap(s.substring(lineSize), lineSize) else s
return formattedString
}
class Box<T> {
private var element: T? = null
fun put(e: T) {
element = e
}
fun get(): T? = element
}
interface Command {
fun execute()
}
data class Coordinates(val x: Int, val y: Int)
class MoveCommand(val coord: Coordinates): Command {
override fun execute() {
println("Moving to position ${coord.x}, ${coord.y}")
}
sudo apt-get install compizconfig-settings-manager
sudo apt-get install compiz-plugins
Open compizconfig-settings-manager with alt-F2, type ccsm.
Scroll down to "Ubuntu Unity Plugin". Choose the tab "Switcher". Disable the alt-tab and shift-alt-tab key bindings. ("Key to start the switcher" and "Key to switch to the previous window in the Switcher".
Click the "Back" button.
r for reading
r+ opens for reading and writing (cannot truncate a file)
w for writing
w+ for writing and reading (can truncate a file)
rb for reading a binary file. The file pointer is placed at the beginning of the file.
rb+ reading or writing a binary file
wb+ writing a binary file
a+ opens for appending
ab+ Opens a file for both appending and reading in binary. The file pointer is at the end of the file if the file exists. The file opens in the append mode.
x open for exclusive creation, failing if the file already exists (Python 3)
# Package.json
"debug": "node_modules/.bin/nodemon --inspect-brk=0.0.0.0:9229 index.js"
# lauch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
@augustovictor
augustovictor / debug-docker-config.sh
Last active October 1, 2018 17:59
Debug vscode docker es6
# docker-compose.yml
...
command: npm run debug
ports:
- "3000:3000"
- "9229:9229"
...
--------------------------------------------------------
# ---- Base Node ----
FROM node:8.9.1-alpine AS base
RUN apk add --no-cache openssl
ENV DOCKERIZE_VERSION v0.6.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
/*
Helper functions to calculate difference in hours, minutes and seconds between two dates
*/
function diffMinutes(initial, final) {
if(initial > final) return 59 + final - initial
return final - initial
}
function getDiffTime(initialDate, finalDate) {
// launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "node",