txt
View squidgame.py
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
# Simulation of https://fivethirtyeight.com/features/can-you-survive-squid-game-riddler/ | |
from random import randint | |
import statistics | |
times = 100000 | |
data = [] | |
# bridge made up of 18 pairs of separated glass squares. | |
BRIDGE_SQUARES = 18 | |
BAD_GLASS = 1 |
View .gitignore
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
# <genignore python> | |
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so |
View request.py
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 os | |
import sys | |
import json | |
import requests | |
from dotenv import load_dotenv | |
load_dotenv() | |
argv = sys.argv[1:] |
View sensei_show_learner_lessons_by_status_and_course.sql
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
-- Sensei: Show Lessons for a Learner by completion status. Also show quiz grade | |
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; | |
use <your-database>; | |
SET @course_id = <your-course-id>; | |
SET @user_id = <your-user-id>; | |
SELECT c.comment_ID, c.user_id, c.comment_post_ID, cm.* |
View publick.py
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
# From calculation, it is expected that the local minimum occurs at x=9/4 | |
cur_x = 6 # The algorithm starts at x=6 | |
gamma = 0.01 # step size multiplier | |
precision = 0.00001 | |
previous_step_size = cur_x | |
df = lambda x: 4 * x**3 - 9 * x**2 | |
while previous_step_size > precision: |
View sensei_learner_stati.sql
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
-- Sensei: Show specific course/lesson status report for a learner | |
-- | |
-- Substitute table names and user id to match your setup | |
SELECT u.ID, COUNT(c.comment_type) AS `cnt`, c.comment_type AS `status_type`, c.comment_approved AS `status` | |
FROM `wp_users` AS u | |
JOIN `wp_comments` AS c ON u.ID = c.user_id | |
WHERE | |
c.comment_type IN ('sensei_course_status', 'sensei_lesson_status') AND | |
u.ID = 1 |
View wpjm_add_custom_field.php
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
<?php | |
/** | |
* Register a custom field (using a bit of Mixtape) | |
* | |
* @throws WPJM_REST_Exception When bad things happen. | |
*/ | |
function register_job_listing_custom_fields() { | |
$env = $this->wpjm_rest_api->environment(); | |
$string_type = $env->type()->definition( 'string' ); |
View euclidean_rhythm.py
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
# Euclidean Rhythm in vanilla py3 | |
def euclidean_rhythm(beats, pulses): | |
"""Computes Euclidean rhythm of beats/pulses | |
Examples: | |
euclidean_rhythm(8, 5) -> [1, 0, 1, 0, 1, 0, 1, 1] | |
euclidean_rhythm(7, 3) -> [1, 0, 0, 1, 0, 1, 0] | |
Args: |
View sensei_cpt_course_do_not_use_with_front.php
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
<?php | |
/* | |
* Plugin Name: Enable Sensei courses to display on /course | |
* Plugin URI: | |
* Description: Enable Sensei courses to display on /course/<course_name> instead of /blog/course/<course_name>, | |
* Author: WooThemes | |
* Author URI: https://woocommerce.com | |
* Requires at least: 4.7.3 | |
* Tested up to: 4.7.3 | |
* Domain path: /lang/ |
NewerOlder