874CodeMirror – A Browser-based Text Editor
- + Themes
- + Full Screen
- + Markdown Mode
- - No bold, italic
872Funky CSS Selectors
https://www.w3.org/TR/css3-selectors/#attribute-substrings
[att=val]
code[class="language-"] {
}
<code class="language-c language-js">
Represents an element with the att attribute whose value contains at least one instance of the substring "val". If "val" is the empty string then the selector does not represent anything.
[att^=val]
Represents an element with the att attribute whose value begins with the prefix "val". If "val" is the empty string then the selector does not represent anything.
[att$=val]
Represents an element with the att attribute whose value ends with the suffix "val". If "val" is the empty string then the selector does not represent anything.
871Syncing Cyberduck Bookmarks with Dropbox
https://trac.cyberduck.io/wiki/help/en/howto/preferences#Hiddenconfigurationoptions
dropbox_path = "/Volumes/3000/Dropbox/Library/Application Support/Cyberduck"
defaults write ~/Library/Preferences/ch.sudo.cyberduck.plist application.support.path dropbox_path 870How to download Videos from Youtube
Update 2025
youtube-dl throws an error in 2025, use yt-dlp instead.
https://github.com/rg3/youtube-dl/blob/master/README.md#readme
Installation
brew install youtube-dl
Downloading a Video
youtube-dl 'https://www.youtube.com/watch?v=1234'
The link needs to be in inverted commas:
OK: youtube-dl 'https://www.youtube.com/watch?v=1234'
NG: youtube-dl https://www.youtube.com/watch?v=1234
Downloading a Playlist
youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' playlist_url
How to select video quality from youtube-dl?
youtube-dl -F playlist_url
[youtube] Setting language
[youtube] playlist_url: Downloading webpage
[youtube] playlist_url: Downloading video info webpage
[youtube] playlist_url: Extracting video information
[info] Available formats for playlist_url:
format code extension resolution note
17 3gp 176x144
36 3gp 320x240
5 flv 400x240
43 webm 640x360
18 mp4 640x360
22 mp4 1280x720 (best)
Select download quality
youtube-dl -f 22 playlist_url
869Pagination in Custom Queries need $paged
...$nr // number of posts
$args = array( 'posts_per_page' => $nr ? $nr : get_option('posts_per_page'), 'paged' => get_query_var('paged', 1), 'post_type' => 'post', ... );
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post(); // display endwhile;
// getPagination()
868Removing Categories on save_post
function onSavePosts($post_id) {
if (wp_is_post_revision($post_id)) return;
// Remove Post Categories, set post categories to empty array wp_set_post_terms($post_id, array(), 'category'); } add_action('save_post', 'onSavePosts');
864Pulling a GitHub Repository with Tokens & Webhooks
Here is how to sync a Wordpress Theme from Github to your own server:
Create a Personal Access Token on GitHub
Webhook on GitHub
https://www.trembl.org/update-my-website.php
Webhook on GitHub for .htaccess protected directory:
https://username:passwd@www.trembl.org/update-my-website.php
Initialise
Go to your tmp directory, init the git repo and pull the repo
cd /my/local/tmp/directory/
git init // initialize git
git reset --hard
git pull https://{$token}@github.com/{$repo}
Update
The update-my-website.php should look something like this:
<?php
// path to local tmp directory
$temp_dir = '/my/local/tmp/directory/';
// path to local theme directory
$theme_dir = "/my/local/theme/directory/";
// access token from GitHub
$token = 'abcdefghijk';
// Repo
$repo = 'github.com/trembl/SuperNiceRepo.git';
// - - - - -
// change to local git directory
chdir($temp_dir);
// resets local git
exec('git reset --hard 2>&1') . ", ";
// get latest from github & store it in $msg
echo exec("git pull https://<span style="background:red">$token</span>@$repo 2>&1");
$msg = exec("git pull https://$token@$repo 2>&1");
if ($msg != "Already up to date.") {
// Only copy if the git repo actually changed
// delete theme dir
echo "\n\nDeleting Theme Directory.\n";
echo exec("rm -rf $theme_dir*"); // * deletes all files within the directory
// Copying Theme from $temp_dir to $theme_dir
echo "\n\nCopying Theme from tmp folder to wp-content.\n";
echo exec("cp -a $temp_dir/* $theme_dir");
// cp -a $temp_dir/* copies everything _except_ invisible files, like .git
} else {
echo($msg);
}
?>
Q & A
update-my-website.php protected by .htaccess?
860 Access a URL behind htaccess/htpasswd
Protect update.php ONLY with .htaccess?
940 Protecting a Single File with .htaccess
I get the following error message: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)/
That means git is not initalized. Run git init
863D3 canvas and Retina screens
function getRetinaRatio() {
var devicePixelRatio = window.devicePixelRatio || 1
var c = document.createElement('canvas').getContext('2d')
var backingStoreRatio = [
c.webkitBackingStorePixelRatio,
c.mozBackingStorePixelRatio,
c.msBackingStorePixelRatio,
c.oBackingStorePixelRatio,
c.backingStorePixelRatio,
1
].reduce(function(a, b) { return a || b })
return devicePixelRatio / backingStoreRatio
}
var ratio = getRetinaRatio() var scaledWidth = width ratio var scaledHeight = height ratio
860Access a URL behind htaccess/htpasswd
Access a htaccess/htpasswd protected URL programmatically:
https://username:passwd@www.trembl.org/protected/area/
See also: Pulling a GitHub Repository with Tokens & Webhooks