This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -i | |
# using shebang with -i to enable interactive mode (auto load .bashrc) | |
set -e #stop immediately if any error happens | |
# Install Open SDK | |
sudo apt-get update | |
sudo apt-get install openjdk-8-jdk -y | |
sudo update-java-alternatives --set java-1.8.0-openjdk-amd64 | |
java -version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 4 * * * root reboot | |
# 0 4 * * * root reboot | |
# https://askubuntu.com/a/655387 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Sometimes in your Django model you want to raise a ``ValidationError`` in the ``save`` method, for | |
some reason. | |
This exception is not managed by Django Rest Framework because it occurs after its validation | |
process. So at the end, you'll have a 500. | |
Correcting this is as simple as overriding the exception handler, by converting the Django | |
``ValidationError`` to a DRF one. | |
""" | |
from django.core.exceptions import ValidationError as DjangoValidationError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain | |
set +e | |
bootanim="" | |
failcounter=0 | |
timeout_in_sec=900 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: openjdk:8-jdk | |
variables: | |
ANDROID_COMPILE_SDK: "29" | |
ANDROID_BUILD_TOOLS: "29.0.3" | |
SDK_TOOLS: "6200805" # from https://developer.android.com/studio/#command-tools | |
EMULATOR_VERSION: "24" | |
before_script: | |
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${SDK_TOOLS}_latest.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Reverse Linked List II: | |
Given the head of a singly linked list and two integers left and right where left <= right, | |
reverse the nodes of the list from position left to position right, and return the reversed list. | |
Follow up: Could you do it in one pass? | |
Example 1: | |
Input: head = [1,2,3,4,5], left = 2, right = 4 | |
Output: [1,4,3,2,5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsonObj = {"doorsWindows":[{'ID':"A","style":"apple"},{'ID':"B","style":"apple"},{'ID':"C","style":"apple"}]} | |
const doorsWindowsIds = [] | |
for (var i = 0; i < jsonObj.doorsWindows.length; i++) { | |
let doorWindow = jsonObj.doorsWindows[i]; | |
doorsWindowsIds.push(doorWindow.ID) | |
} | |
console.log(doorsWindowsIds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Node Depths: | |
The distance between a node in a Binary Tree and the tree's root is called the node's depth. | |
Write a function that takes in a Binary Tree and returns the sum of its nodes' depths. | |
Each BinaryTree node has an integer value, a left child node, and a right child node. | |
Children nodes can either be BinaryTree nodes themselves or None / null. | |
https://www.algoexpert.io/questions/Node%20Depths | |
""" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import json | |
import logging | |
import pickle | |
import sys | |
import timeit | |
from time import sleep | |
from django.conf import settings | |
from django.core.serializers.json import DjangoJSONEncoder |