Snippets Collections
How to
To run stressberry on your computer, simply install it with

[sudo] apt install stress
python3 -m pip install stressberry
Users of Arch Linux ARM can install from the official repos

[sudo] pacman -S stressberry
and run it with

stressberry-run out.dat
stressberry-plot out.dat -o out.png
(Use MPLBACKEND=Agg stressberry-plot out.dat -o out.png if you're running the script on the Raspberry Pi itself.)

If it your computer can't find the stressberry tools after installation, you might have to add the directory $HOME/.local/bin to your path:

export PATH=$PATH:/home/pi/.local/bin
(You can also put this line in your .bashrc.)

The run lets the CPU idle for a bit, then stresses it with maximum load for 5 minutes, and lets it cool down afterwards. The entire process takes 10 minutes. The resulting data is displayed to a screen or, if specified, written to a PNG file.

If you'd like to submit your own data for display here, feel free to open an issue and include the data file, a photograph of your setup, and perhaps some further information.

Testing
To run the tests, just check out this repository and type

pytest
test('should verify typed', async () => {
  const browser = await puppeteer.launch({
    headless: false,
    slowMo: 10,
    args: ['--window-size=1920,1080']
  })
  const page = await browser.newPage()
  await page.goto(url)
  await page.type('.input-text', 'Hello World!')

  const finalText = await page.$eval('input.input-text', el => el.textContent)
  expect(finalText).toBe(finalText)
})
const {getIntroduction} = require('./util')

test('should output name and age', () => {
  const text = getIntroduction('Max', 20)
  expect(text).toBe('Max is 20 years old')
})
"scripts": {
  "test": "jest",
   "start": "node index.js"
},
"devDependencies": {
  "jest": "^26.6.3"
}
# -------------------------------------------------------------------------------------------
# email retrieving script
# -------------------------------------------------------------------------------------------
#!/usr/bin/env python3

import csv
import sys


def populate_dictionary(filename):
  """Populate a dictionary with name/email pairs for easy lookup."""
  email_dict = {}
  with open(filename) as csvfile:
    lines = csv.reader(csvfile, delimiter = ',')
    for row in lines:
      name = str(row[0].lower())
      email_dict[name] = row[1]
  return email_dict

def find_email(argv):
  """ Return an email address based on the username given."""
  # Create the username based on the command line input.
  try:
    fullname = str(argv[1] + " " + argv[2])
    # Preprocess the data
    email_dict = populate_dictionary('/home/{{ username }}/data/user_emails.csv')
     # If email exists, print it
    if email_dict.get(fullname.lower()):
      return email_dict.get(fullname.lower())
    else:
      return "No email address found"
  except IndexError:
    return "Missing parameters"

def main():
  print(find_email(sys.argv))

if __name__ == "__main__":
  main()


# -------------------------------------------------------------------------------------------
# Unit test script
# -------------------------------------------------------------------------------------------

#!/usr/bin/env python3

import unittest
from emails import find_email


class EmailsTest(unittest.TestCase):
  def test_basic(self):
    testcase = [None, "Bree", "Campbell"]
    expected = "breee@abc.edu"
    self.assertEqual(find_email(testcase), expected)

  def test_one_name(self):
    testcase = [None, "John"]
    expected = "Missing parameters"
    self.assertEqual(find_email(testcase), expected)

  def test_two_name(self):
    testcase = [None, "Roy","Cooper"]
    expected = "No email address found"
    self.assertEqual(find_email(testcase), expected)

if __name__ == '__main__':
  unittest.main()

star

Mon Apr 04 2022 15:21:45 GMT+0000 (UTC) https://github.com/nschloe/stressberry

#testing
star

Sat Feb 19 2022 13:02:25 GMT+0000 (UTC) https://blog.bitsrc.io/improve-react-performance-using-lazy-loading-and-suspense-933903171954

#react #testing #performance
star

Sat May 08 2021 17:59:57 GMT+0000 (UTC)

#jest #nodejs #testing
star

Sun Mar 28 2021 07:25:37 GMT+0000 (UTC)

#python #testing

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension