- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
- They are the people who get things done. Effective Engineers produce results.
version: '3.4' | |
services: | |
redis: | |
image: 'redis:alpine' | |
ports: | |
- 6379:6379 |
from contextlib import ExitStack | |
import random | |
import unittest | |
from unittest.mock import patch | |
class TryMockUsingExitStackTest(unittest.TestCase): | |
def test_mock_random_twice(self): | |
with ExitStack() as stack: | |
mock_randrange = stack.enter_context( |
import random | |
import unittest | |
from unittest.mock import patch | |
class TryMockUsingContextManagerTest(unittest.TestCase): | |
def test_mock_random_twice(self): | |
with patch('__main__.random.randrange') as mock_randrange: | |
with patch('__main__.random.randint') as mock_randint: | |
try_mock_using_context_manager() |
import random | |
import unittest | |
from unittest.mock import patch | |
class TryMockUsingDecoratorTest(unittest.TestCase): | |
@patch('__main__.random.randrange') | |
@patch('__main__.random.randint') | |
def test_mock_random_twice(self, mock_randint, mock_randrange): | |
try_mock_using_decorator() |
import csv | |
from faker import Faker | |
fake = Faker() | |
with open('transactions.csv', 'r') as file_: | |
with open('anonymized_transactions.csv', 'w') as new_file: | |
reader = csv.DictReader(file_) | |
writer = csv.DictWriter(new_file, fieldnames=reader.fieldnames) |
<?php | |
/* | |
* Plugin Name: WooCommerce Cart Count Shortcode | |
* Plugin URI: https://github.com/prontotools/woocommerce-cart-count-shortcode | |
* Description: Display a link to your shopping cart with the item count anywhere on your site with a customizable shortcode. | |
* Version: 1.0.4 | |
* Author: Pronto Tools | |
* Author URI: http://www.prontotools.io | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
require 'rack/jekyll' | |
require "rack/rewrite" | |
use Rack::Auth::Basic, "Restricted Area" do |username, password| | |
[username, password] == ['admin', 'admin'] or [username, password] == ['zkan', '123'] or [username, password] == ['cory', 'cool'] | |
end | |
use Rack::Rewrite do | |
rewrite %r{/(.+)}, lambda { |match, rack_env| | |
if File.exists?('_site/' + match[1] + '.html') |
#!/usr/bin/env ruby | |
icon_list = "alligator, anteater, armadillo, auroch, axolotl, badger, bat, beaver, buffalo, camel, chameleon, cheetah, chipmunk, chinchilla, chupacabra, cormorant, coyote, crow, dingo, dinosaur, dolphin, duck, elephant, ferret, fox, frog, giraffe, gopher, grizzly, hedgehog, hippo, hyena, jackal, ibex, ifrit, iguana, koala, kraken, lemur, leopard, liger, llama, manatee, mink, monkey, narwhal, nyan cat, orangutan, otter, panda, penguin, platypus, python, pumpkin, quagga, rabbit, raccoon, rhino, sheep, shrew, skunk, slow loris, squirrel, turtle, walrus, wolf, wolverine, wombat" | |
for icon in icon_list.split ', ' do | |
element = icon.sub ' ', '' | |
`curl https://ssl.gstatic.com/docs/common/profile/#{element}_lg.png -o icons/#{element}.png` | |
end |
""" | |
How Not To Sort By Average Rating: | |
http://www.evanmiller.org/how-not-to-sort-by-average-rating.html | |
Note: Lower bound of a 95% confidence interval | |
""" | |
import math | |
import unittest | |