Skip to content

Instantly share code, notes, and snippets.

import random
months = 3
every_n_seconds = 5
points = []
for i in range(months * 30 * 24 * 60 * 60 // every_n_seconds):
points.append([i, random.randint(1, 100)])
with open("data.csv", "w") as f:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
version: "3.9"
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
$result = $repository?->getUser(5)?->name;
<?
if (is_null($repository)) {
$result = null;
} else {
$user = $repository->getUser(5);
if (is_null($user)) {
$result = null;
} else {
$result = $user->name;
}
class Person {
public function __construct(
private string $firstName,
private string $lastName,
protected int $age,
public ?string $job
){}
}
class Person {
private string $firstName;
private string $lastName;
protected int $age;
public ?string $job;
public function __construct(
class Person {
public string $firstName;
public string $lastName;
public int $age;
public ?string $job;
}
func parseWithBlackMagic(inputString string) int {
isAm := inputString[len(inputString)-2] == 'A'
number := int(inputString[0]) - '0'
if len(inputString) > 3 {
number = number*10 + int(inputString[1]) - '0'
}
if !isAm {
number += 12
func parseWithStringManipulationWithoutHasSuffix(inputString string) int {
isAm := inputString[len(inputString)-2] == 'A'
number, _ := strconv.Atoi(inputString[:len(inputString) - 2])
if !isAm {
number += 12
}
return number
}