This file contains 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
fn main() { | |
let mut v = vec![1, 2, 3, 4, 5]; | |
let exp = 2; | |
for num in &mut v { | |
*num = i32::pow(*num, exp); | |
} | |
println!("{:?}", v); | |
} |
This file contains 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 java.util.Arrays; | |
class Scratch { | |
public static int maxProduct(int[] numbers) { | |
int length = numbers.length; | |
if (length < 2) { | |
throw new IllegalArgumentException(String.format("Require at least 2 numbers. But given: %s", Arrays.toString(numbers))); | |
} | |
int min1 = numbers[0]; |
This file contains 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 java.util.List; | |
import java.util.stream.Collectors; | |
class Scratch { | |
public static void countVowelAndConsonant(String s) { | |
String VOWELS = "aeiouy"; | |
String normalized = s.toLowerCase().trim(); | |
List<Integer> letters = normalized.chars() |
This file contains 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 java.util.stream.IntStream; | |
class Scratch { | |
public static boolean palindromeChecker(String s) { | |
String normalizedString = s.trim().toLowerCase(); | |
return IntStream.range(0, normalizedString.length() / 2) | |
.allMatch(i -> | |
normalizedString.charAt(i) == | |
normalizedString.charAt(normalizedString.length() - i - 1)); |
This file contains 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
# Create config file | |
$ ipython profile create | |
$ vim <ipython_config_file> | |
c.InteractiveShellApp.extensions = ['autoreload'] | |
.InteractiveShellApp.exec_lines = ['%autoreload 2'] |
This file contains 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
#!/usr/bin/env python | |
import math | |
def generate_bins(size: int, count: int): | |
""" | |
>>> list(generate_bins(size=100, count=300)) | |
[100, 100, 100] | |
>>> list(generate_bins(size=100, count=301)) | |
[100, 100, 100, 1] |
This file contains 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 pytest | |
from sqlalchemy import ( | |
create_engine, | |
Column, | |
Integer, | |
String, | |
Table, | |
ForeignKey, | |
PrimaryKeyConstraint, | |
) |
This file contains 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 ipyvuetify as v | |
import traitlets | |
import json | |
class MyForm(v.VuetifyTemplate): | |
email = traitlets.Unicode('').tag(sync=True) | |
password = traitlets.Unicode('').tag(sync=True) | |
isValid = traitlets.Bool(False).tag(sync=True) | |
result = traitlets.Dict({}).tag(sync=True) | |
template = traitlets.Unicode(''' |
This file contains 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 sqlalchemy | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String, ForeignKey | |
from sqlalchemy.orm import sessionmaker, relationship, backref | |
engine = sqlalchemy.create_engine('sqlite:///tmp.db') | |
Base = declarative_base() | |
class Answer(Base): |
This file contains 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
pipx install tubex | |
tubex --outdir foo download-mp4 https://www.youtube.com/watch?v=LABGimhsEys |
NewerOlder