txt
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 |
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 |
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:] |
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.* |
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: |
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 |
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' ); |
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: |
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