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
| <script type="text/javascript"> | |
| window.onbeforeunload = function() { | |
| return "Dude, are you sure you want to leave? Think of the kittens!"; | |
| } | |
| </script> |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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 | |
| $news_term = get_term_by('name', 'news', 'category'); | |
| if(!empty($news_term)) { | |
| $news_child_terms = get_categories(array( | |
| 'parent' => $news_term->term_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
| <?php | |
| Route::get('protected', array('before' => 'auth|role:admin', function() { | |
| return "Only admins can see this"; | |
| })); | |
| Route::filter('role', function ($role) { | |
| if ( ! Auth::user()->has_role( $role ) ) | |
| { | |
| return Response::error("401"); // not authorized |
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://www.abeautifulsite.net/vertically-centering-bootstrap-modals/ | |
| /** | |
| * Vertically center Bootstrap 3 modals so they aren't always stuck at the top | |
| */ | |
| $(function() { | |
| function reposition() { | |
| var modal = $(this), | |
| dialog = modal.find('.modal-dialog'); | |
| modal.css('display', 'block'); | |
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
| /** | |
| * Use value of post meta for something when the post | |
| * meta changes | |
| * @param integer $meta_id ID of the meta data field | |
| * @param integer $post_id Post ID | |
| * @param string $meta_key Name of meta field | |
| * @param string $meta_value Value of meta field | |
| */ | |
| function saveYouTubeInfo($meta_id, $post_id, $meta_key='', | |
| $meta_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
| function get_cat_ID( $cat_name ) { | |
| $cat_name = _wp_specialchars( $cat_name ); // get_term_by expects $cat_name to be escaped | |
| $cat = get_term_by( 'name', $cat_name, 'category' ); | |
| } |
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
| du -h --max-depth=1 /var/www | sort -nk1 |
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
| // swap the keybindings for paste and paste_and_indent | |
| { "keys": ["super+v"], "command": "paste_and_indent" }, | |
| { "keys": ["super+shift+v"], "command": "paste" } |