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
#include <LiquidCrystal.h> | |
#define JOYSTICK_X_ANALOG_PIN A0 | |
#define JOYSTICK_Y_ANALOG_PIN A1 | |
const int LCD_SCREEN_CHAR_WIDTH = 16; | |
const int LCD_SCREEN_ROW_HEIGHT = 2; | |
const int BUTTON_PIN = 7; |
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 | |
import subprocess | |
from os.path import expanduser, join, exists | |
# We expect rbenv and rvm to be installed in their default locations. Can | |
# be updated to find them, if necessary. | |
rbenv_path = expanduser('~/.rbenv') | |
rvm_path = expanduser('~/.rvm') |
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
def contiguous_sublists(vals): | |
sub_lists = [] | |
for ind, a in enumerate(vals): | |
sub_lists.append([a]) | |
for b in range(ind+1, len(vals)): | |
sub_lists.append(sub_lists[-1] + [vals[b]]) | |
return sub_lists |
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 collections import OrderedDict | |
from datetime import datetime | |
def sort_dict_by_date(the_dict, date_format): | |
# Python dicts do not hold their ordering so we need to make it an | |
# ordered dict, after sorting. | |
return OrderedDict(reversed(sorted( | |
the_dict.items(), | |
key=lambda x: datetime.strptime(x[0], date_format) |
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 random import randint, random | |
from math import floor | |
def fisher_yates_shuffle(the_list): | |
list_range = range(0, len(the_list)) | |
for i in list_range: | |
j = randint(list_range[0], list_range[-1]) | |
the_list[i], the_list[j] = the_list[j], the_list[i] | |
return the_list |
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
# To the not-so-mathematically-inclined, this function may look like pure witch- | |
# craft. That's why I shall describe how it works. | |
# | |
# Let's say we start with an initial number of `13`, we expect an output of `31`, | |
# right? Let's see: | |
# | |
# reverse_number(13) | |
# | |
# num = 13 | |
# reversed_num = 0 |
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
#NoEnv | |
#NoTrayIcon | |
#IfWinActive ahk_class WorkerW | |
^Right::^#Right | |
^Left::^#Left |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example for traverseToAncestor</title> | |
</head> | |
<body> | |
<div class="top-ancestor"> | |
<div class="grandparent"> | |
<div class="parent"> | |
<div class="child"></div> |
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
function redirectWithGetDataChange(key, value) { | |
var getData = window.location.search.substr(1).split("&"), | |
getKeyValue = null, | |
getKeyChanged = false; | |
for (var i=0; i<getData.length; i++) { | |
getKeyValue = getData[i].split("="); | |
if (getKeyValue[0] == key) { | |
getData[i] = key + "=" + 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
import sys | |
def generate_csv_data_from_html_table(html): | |
csv_header = "" | |
csv_rows = [] | |
rows = create_rows_from_trs(remove_tab_and_newline(html)) | |
for row in rows: | |
if not row.find("<th>") == -1: | |
csv_header = row.replace("<th>", "").replace("</th>", ",") | |
elif not row.find("<td>") == -1: |
NewerOlder