-
jq — https://jqlang.org/ — "like sed for JSON data"
There are several options available for installing jq. I prefer to use Homebrew:
brew install jq
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
// "Pseudorandom", because it's not guaranteed to be truly random. | |
// Express a floating point random number as base 26 and remove "0." from the beginning. | |
// Next, to make it alphabetical, replace digits 0-9 with letters q-z. | |
// @returns {string} Usually 10 to 13 characters in length | |
Math.random().toString(26).substring(2).replace(/[0-9]/g, function (c) {return 'qrstuvwxyz'[c]}); | |
// Alternate, non-function versions (which is more efficient?) | |
Math.random().toString(26).substring(2).split('').map(c => 'qrstuvwxyz'[c] || c).join(''); // split to array, replace, join to string | |
Math.random().toString(26).substring(2).replace(/[0-9]/g, c => 'qrstuvwxyz'[c]); // examine only characters 0-9 | |
Math.random().toString(26).substring(2).replace(/./g, c => 'qrstuvwxyz'[c] || c); // examine all characters |
After you made some cool games or apps with Pythonista, you may want to make it run as a standaone app on iPad/iPhone and possibly share it on the AppStore. This how-to tells you how to do it.
- Pythonista code you wrote
- A Mac with Xcode 7.1 installed
- iPhone/iPad running iOS 9
- Download PythonistaProjectTemplate.zip. The original PythonistaProjectTemplate described at http://olemoritz.net/pythonista-15-whats-new-and-whats-missing.html does not work with Xcode 7. I updated it to work with Xcode 7 and added a more interesting example than the plain old Hello World thing.
- Unzip the file and open the project in Xcode 7.1. In project settings, change the Bundle Identifier from com.yuhangwang.pythonistaproject to something else.
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
/** | |
* Problem: `DateTime::getTimestamp` returns **_`int`_**! Calculations such as the following | |
* are incorrect if the `DateTime` object includes fractions of seconds: | |
* | |
* ```php | |
* $durationSeconds = strval($endTime->getTimestamp() - $startTimestamp); | |
* ``` | |
* | |
* `DateTime::diff` can subtract properly, but only under PHP 7.1. (Curiously, | |
* `DateTime::getTimestamp` still returns `int` under PHP 7.1!) |
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
Please see the README.md file in this gist. |
- Install Karabiner-Elements: https://pqrs.org/osx/karabiner/
- In Karabiner-Elements' preferences
- Disable the Touch Bar's esc key
- Simple Modifications
- Target Device: "No product name (No manufacturer name)", is the Touch Bar
- From key: escape
- To key: vk_none (disable this key)
- Target Device: "No product name (No manufacturer name)", is the Touch Bar
- Simple Modifications
- Make `~ act as esc and fn + `~ act as `~
- Disable the Touch Bar's esc key
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
date_default_timezone_set(DateTimeZone::listIdentifiers(DateTimeZone::UTC)[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
sudo /bin/env bash |
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
/* Begin https://example.org/path/to/wiki/MediaWiki:Common.js */ | |
/* CSS placed here will be applied to all skins */ | |
/* Simple CSS change to make page tables of contents float on the right of the page, | |
letting content wrap around it. To give a little separation from the content, | |
a wide white border is used instead of a transparent margin. The border color may | |
need to be changed to look good with other MediaWiki skins. */ | |
/* Float table of contents (TOC) to the right, so text wraps around it */ | |
/* Change thin gray border to a wide white one instead of using a transparent margin */ |
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
/* Begin https://example.org/path/to/wiki/MediaWiki:Common.js */ | |
/* Any JavaScript here will be loaded for all users on every page load. */ | |
/* This file will be included in response to requests like https://example.org/path/to/wiki/index.php?action=raw&smaxage=0&gen=js */ | |
/* Hide the table of contents each time any page is loaded. */ | |
function hideToc() { | |
try { | |
// Detect whether the page's TOC is displayed. | |
if (document.getElementById('toc').getElementsByTagName('ul')[0].style.display != 'none') { |