Pi Day is an annual celebration of the mathematical constant π (pi). Pi Day is observed on March 14 (3/14 in the month/day format) since 3, 1, and 4 are the first three significant figures of π. It was founded in 1988 by Larry Shaw, an employee of the San Francisco, California science museum, the Exploratorium.
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 os | |
| def create_dirs_by_filenames(filenames, parent_dir): | |
| mode = 0o777 | |
| for directory in filenames: | |
| os.mkdir(os.path.join(parent_dir, directory), mode) | |
| def get_filenames(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
| import os | |
| EXTENSIONS = ['py', 'rb', 'cs', 'ex', 'js', 'go', 'rs', 'dart', 'php', 'sql'] | |
| def create_files_by_extension_given_a_filename(name, directory): | |
| for extension in EXTENSIONS: | |
| file = f"{name}.{extension}" | |
| if os.path.exists(os.path.join(directory, file)): | |
| print('{0}: already exists!'.format(file)) |
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
| namespace Fibonacci; | |
| /// <summary> | |
| /// The Fibonacci sequence is a sequence of numbers where a number is the sum of the two preceding numbers. | |
| /// The first 10 numbers in the Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34. | |
| /// </summary> | |
| public static class Fibonacci | |
| { | |
| /// <summary> | |
| /// Fibonacci in a recursive 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
| from numpy import matrix | |
| def fib(n): | |
| return (matrix( | |
| '0 1; 1 1' if n >= 0 else '-1 1; 1 0', object | |
| ) ** abs(n))[0, 1] | |
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
| # frozen_string_literal: true | |
| mailer = ActionMailer::Base.new | |
| mailer.delivery_method | |
| mailer.smtp_settings | |
| mailer.mail(from: '[email protected]', to: '[email protected]', subject: 'Testing email', body: "Hello, you've got mail!").deliver! |
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
| # python -m pip install requests | |
| import requests | |
| url = "https://api-us.cometchat.io/v2" | |
| headers = { | |
| "accept": "application/json", | |
| "Content-Type": "application/json", | |
| "Accept": "application/json", | |
| "appId": "---", |
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
| -- The below query is used to fetch all the role names from the 'pg_roles' system catalog table. | |
| -- It will return a list of all user (role) names in the current PostgreSQL database. | |
| SELECT rolname FROM pg_roles; | |
| -- This command is used to create a new PostgreSQL user with the specified username and password. | |
| -- In this case, the newly created username is 'username' and the password is 'P@55w0rd'. | |
| CREATE USER username WITH PASSWORD 'P@55w0rd'; | |
| -- This command grants all privileges to the user 'username' on the database 'dbname'. | |
| -- These privileges include SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, and USAGE |
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
| # This command will list all your environments which are setup in Elastic Beanstalk (EB) | |
| $ eb list | |
| EnvironmentName1 # Name of the first environment | |
| EnvironmentName2 # Name of the second environment | |
| EnvironmentName3 # Name of the third environment | |
| # This command is used to display the status of the specified environment (EnvironmentName1) | |
| $ eb status EnvironmentName1 | |
| # The following command will set an environment variable (ENV_VAR_NAME) to a specific value (value) |
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
| DO $$ | |
| DECLARE | |
| r RECORD; | |
| row_count BIGINT; | |
| BEGIN | |
| FOR r IN (SELECT relname FROM pg_stat_user_tables) LOOP | |
| EXECUTE 'SELECT COUNT(*) FROM ' || quote_ident(r.relname) INTO row_count; | |
| RAISE NOTICE 'Table: %, Row count: %', r.relname, row_count; | |
| END LOOP; | |
| END $$; |
OlderNewer