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
const { Component } = wp.element; | |
import { __, _x } from '@wordpress/i18n'; | |
const { BACKSPACE, DELETE, F10 } = wp.keycodes; | |
function isTmceEmpty(editor) { | |
// When tinyMce is empty the content seems to be: | |
// <p><br data-mce-bogus="1"></p> | |
// avoid expensive checks for large documents | |
const body = editor.getBody(); |
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
def insertion_sort(alist): | |
marker = 1 | |
while marker < len(alist): | |
current = alist[marker] | |
second_marker = marker - 1 | |
while current < alist[second_marker] and second_marker >= 0: | |
alist[second_marker + 1] = alist[second_marker] | |
second_marker -= 1 | |
alist[second_marker + 1] = current |
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
def merge_sort(alist): | |
if len(alist) > 1: | |
mid = len(alist) // 2 | |
lefthalf = alist[:mid] | |
righthalf = alist[mid:] | |
merge_sort(lefthalf) | |
merge_sort(righthalf) | |
i = j = k = 0 |
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
def quicksort(alist): | |
if len(alist) < 2: | |
return alist | |
else: | |
pivot = alist[0] | |
less = [num for num in alist[1:] if num <= pivot] | |
greater = [num for num in alist[1:] if num > pivot] | |
return quicksort(less) + [pivot] + quicksort(greater) |
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
"""I use arrays to implement the heap and array content start at index 1""" | |
def max_heapify(array, i): | |
left = 2 * i | |
right = 2 * i + 1 | |
N = len(array) - 1 | |
if left <= N and array[left] > array[i]: | |
largest = left | |
else: | |
largest = i |
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
def heauristic(a, b): | |
(x1, y1) = a | |
(x2, y2) = b | |
return abs(x1 - x2) + abs(y1 - y2) | |
def a_star_search(graph, start, goal): | |
frontier = PriorityQueue() | |
frontier.put(start, 0) | |
came_from = {} |
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
def dijkstra_search(graph, start, goal): | |
frontier = PriorityQueue() | |
frontier.put(start, 0) | |
came_from = {} | |
cost_so_far = {} | |
came_from[start] = None | |
cost_so_far[start] = 0 | |
while not frontier.empty(): | |
current = frontier.get()[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
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import { | |
PostMediaContainer, | |
PostTextContainer, | |
} from './components'; | |
import PostContent from './PostContent'; |
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 React from 'react'; | |
import getUrls from 'get-urls'; | |
import linkifyHtml from 'linkifyjs/html'; | |
import PropTypes from 'prop-types'; | |
import { | |
PostMediaContainer, | |
PostTextContainer, | |
} from './components'; |
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 React from 'react'; | |
import { mount, shallow } from 'enzyme'; | |
import { | |
PostMediaContainer, | |
PostTextContainer, | |
} from './components'; | |
import PostContent from './PostContent'; |
NewerOlder