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
# Fluid Video Wrapper | |
Make videos fluid and keep video proportion | |
## Markup | |
Padding top style attribute is calculated. | |
```html | |
<div class="fluid-width-video-wrapper" style="padding-top: 59%"> | |
<iframe ...></iframe> | |
</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
# Remove all extended attributes (xattr) in a directory | |
# i.e: drwxr-xr-x@ directory/file -> drwxr-xr-x directory/file | |
xattr -c -r directory/ | |
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
// Convert a NodeList to Array | |
// http://davidwalsh.name/nodelist-array | |
var nodesArray = [].slice.call(document.querySelectorAll("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
<?php | |
function autoset_featured() { | |
global $post; | |
$already_has_thumb = has_post_thumbnail($post->ID); | |
if (!$already_has_thumb) { | |
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); | |
if ($attached_image) { | |
foreach ($attached_image as $attachment_id => $attachment) { | |
set_post_thumbnail($post->ID, $attachment_id); | |
} |
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: http://stackoverflow.com/questions/23393284/how-to-check-which-directory-is-occupying-more-space-on-a-unix-machine | |
du -k -d1 /path/to/directory | sort -rn | head -5 |
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
# DB | |
CREATE DATABASE wordpress; | |
# User | |
CREATE USER wordpressuser@localhost; | |
# User -> DB | |
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password"); | |
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password'; |
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 isPrime(number) { | |
// If your browser doesn't support the method Number.isInteger of ECMAScript 6, | |
// you can implement your own pretty easily | |
if (typeof number !== 'number' || !Number.isInteger(number)) { | |
// Alternatively you can throw an error. | |
return false; | |
} | |
if (number < 2) { | |
return false; |
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
## See http://www.linfo.org/tar.html | |
# Tar & Compress: -j (for bzip2), -z (for gzip) and -Z (for compress) | |
tar -cvjf files.tar.bz2 file4 file5 file6 | |
# Decompress: -x | |
tar -xjvf files.tar.bz2 | |
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
# Backup | |
mysqldump -u user -p'user-password' database_name > dumpfilename.sql | |
# Restore | |
mysqldump -u user -p'user-password' database_name < dumpfilename.sql |