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 json | |
| import logging | |
| from datetime import datetime | |
| logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s') | |
| def date_to_timestamp(date_str): | |
| try: | |
| dt = datetime.fromisoformat(date_str.replace('Z', '+00:00')) | |
| return int(dt.timestamp()) |
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
| FROM alpine:latest | |
| RUN apk add \ | |
| --update \ | |
| --no-cache ansible && \ | |
| rm -rf /tmp/* /var/cache/apk |
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 pytube | |
| url = input("Enter video url: ") | |
| path="/etc/" | |
| pytube.YouTube(url).streams.get_highest_resolution().download(path) |
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 userValidator = { | |
| set(object, prop, value) { | |
| const validProps = ['name', 'email']; | |
| if(!validProps.includes(prop)) { | |
| throw new Error(`Can't set ${prop}`); | |
| } else { | |
| object[prop] = value; | |
| return true; | |
| } | |
| }, |
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 obj = { | |
| a: 1, | |
| ...(true && { b: 5 }), | |
| ...(false && { c: 10 }), | |
| }; | |
| obj; // output: { a: 1, b: 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
| #!/bin/bash | |
| HOST=$1 | |
| # port defaults to 8080 | |
| PORT=${2:-8080} | |
| RETRIES=50 | |
| echo -n "Waiting for keycloak to start on ${HOST}:${PORT}" | |
| # loop until we connect successfully or failed | |
| until curl -f -v "http://${HOST}:${PORT}/" >/dev/null 2>/dev/null |
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
| $smtpServer = "smtp.gmail.com" | |
| $mail = new-object Net.Mail.MailMessage | |
| $mail.From = "" | |
| $mail.To.Add("") | |
| $mail.Subject = "Subject" | |
| $mail.Body = "Body" | |
| $smtp = new-object Net.Mail.SmtpClient($smtpServer, 465) | |
| $smtp.EnableSs1 = $true | |
| $SMTP.Credentials = New-Object System.Net.NetworkCredential(MAIL, PASSWORD) | |
| $smtp.Send($mail) |
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
| docker exec -it b691cd6a3902 /opt/jboss/keycloak/bin/standalone.sh \ | |
| -Djboss.socket.binding.port-offset=100 \ | |
| -Dkeycloak.migration.action=export \ | |
| -Dkeycloak.migration.provider=singleFile \ | |
| -Dkeycloak.migration.file=/tmp/keycloak-export.json |
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 people = [ | |
| { name: 'Naruto', age: 24 }, | |
| { name: 'Sasuke', age: 32 }, | |
| { name: 'Minato', age: 42 }, | |
| { name: 'Kakashi', age: 36 } | |
| ] | |
| const maxBy = (arr, key) => arr.reduce((max,obj) => { | |
| return max[key] >= obj[key] ? max : obj) | |
| }, {}) |
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
| def capitalizeAll(args: String*) = { | |
| args.map { arg => | |
| arg.capitalize | |
| } | |
| } | |
| capitalizeAll("rarity", "applejack") |
NewerOlder