f8lrebel
f8lrebel
Reputation Top 5%
Sam Hall
4 Snippets  (159th place)
Published
0 Channels
Created
1 Channel
Following
128 points  (233rd place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Junior Commenter
Junior Judge
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Senior Autobiographer
Junior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by f8lrebel

public by f8lrebel  366093  3  4  0

Original project here: http://designitcodeit.com/i/11

Original project here: http://designitcodeit.com/i/11: index.html script.js style.css
CSS
<ul class="comments">
  <li class="comment">
    <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo1.png" alt="Kasper"></a>
    <div class="meta">Kasper | 2012.07.24 14:58 <a class="reply">Reply</a></div>
    <div class="body">Cupcake ipsum dolor sit amet. Icing donut cheesecake muffin marzipan chocolate biscuit. Sweet roll chocolate marzipan.</div>
  </li>
  <li class="comment level-2">
    <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo-default.png" alt="Photo"></a>
    <div class="meta">John | 2012.07.24 15:21 <a class="reply">Reply</a></div>
    <div class="body">Candy soufflé bear claw apple pie bear claw marshmallow. Jelly brownie wafer chocolate jelly.marzipan pastry sesame snaps apple pie.</div>
  </li>
  <li class="comment level-3">
    <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo-default.png" alt="Photo"></a>
    <div class="meta">Jane | 2012.07.24 15:32 <a class="reply">Reply</a></div>
    <div class="body">Tart apple pie bonbon applicake sesame snaps sugar plum.</div>
  </li>
  <li class="comment level-4">
    <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo-default.png" alt="Photo"></a>
    <div class="meta">Jane | 2012.07.24 15:32 <a class="reply">Reply</a></div>
    <div class="body">Tart apple pie bonbon applicake sesame snaps sugar plum.</div>
  </li>
  <li class="comment">
    <a href="#" title="View this user profile" class="photo"><img src="http://designitcodeit.com/live/45S6P0fit0nM/img/photo1.png" alt="Kasper"></a>
    <div class="meta">Kasper | 2012.07.24 14:58 <a class="reply">Reply</a></div>
    <div class="body">Cupcake ipsum dolor sit amet. Icing donut cheesecake muffin marzipan chocolate biscuit.</div>
  </li>
</ul>

/* 
 * Comments thread for Design it & Code it
 * http://designitcodeit.com/i/11
 */

html {
  background: #fff url(http://designitcodeit.com/live/45S6P0fit0nM/img/bg.png);
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
body {
  max-width: 480px;
  width: 100%;
  margin: 30px auto 0 auto;
}
a { cursor: pointer; }

/**
 * Customs
 */
.comments:after { border-color: #fff; }
.comments:before { background-color: #fff; }
.comments .comment {
  background: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 10px 15px;
}
.comments [class*="level-"] .photo:before { background-color: #fff; }
.comments .meta { color: #ccc; }
.comments .meta a { color: inherit; }
.comments .meta a:hover { color: #34b5d0; }
.comments .body { color: #888; }

/**
 * Comments Thread
 */
.comments {
  list-style-type: none;
  padding: 5px 0 0 46px;
  position: relative;
  margin: 0 0 0 12px;
}
.comments:before,
.comments .comment,
.comments .comment:after,
.comments .comment:before,
.comments .photo img,
.comments [class*="level-"] .photo:before {
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.comments:after,
.comments:before {
  display: block;
  content: '';
  position: absolute;
}
.comments:before {
  border-radius: 0 0 5px 5px;
  height: 100%;
  width: 8px;
  left: 0;
  top: 0;
}
.comments:after {
  box-shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.4) inset;
  border-width: 4px;
  border-style: solid;
  border-radius: 18px;
  height: 10px;
  width: 10px;
  left: -5px;
  top: -16px;
  z-index: -1;
}
.comments .comment {
  margin-bottom: 10px;
  position: relative;
}
.comments .comment:after,
.comments .comment:before {
  border-radius: 10px;
  background-color: #fff;
  position: absolute;
  display: block;
  content: '';
}
.comments .comment:after {
  width: 12px;
  height: 12px;
  left: -14px;
  top: 7px;
}
.comments .comment:before {
  width: 5px;
  height: 5px;
  left: -22px;
  top: 16px;
}
.comments .photo {
  position: absolute;
  left: -60px;
  top: 2px;
}
.comments .photo img {
  border: 1px solid #fff;
  border-radius: 32px;
  overflow: hidden;
}
.comments .meta { margin-bottom: 5px; }
.comments .meta .reply { display: none; float: right; }
.comments .comment:hover .reply { display: block; }
.comments [class*="level-"] .photo:before {
  display: block;
  content: '';
  position: absolute;
  margin-top: -2px;
  height: 4px;
  width: 20px;
  left: -10px;
  top: 50%;
  z-index: -1;
}
.comments .level-2 { margin-left: 30px; }
.comments .level-3 { margin-left: 50px; }
.comments .level-4 { margin-left: 70px; }
.comments .level-5 { margin-left: 90px; }
.comments .level-6 { margin-left: 110px; }
.comments .level-3 .photo:before { width: 40px; left: -30px;}
.comments .level-4 .photo:before { width: 60px; left: -50px;}
.comments .level-5 .photo:before { width: 80px; left: -70px;}
.comments .level-6 .photo:before { width: 100px; left: -90px;}

;

public by f8lrebel  3044  2  4  0

How to get related posts in WordPress

How to get related posts in WordPress: function.php
PHP
<?php
// get current post categories and tags
$categories = get_the_category($post->ID);
$tags = get_the_tags($post->ID);
if ($categories || $tags) {
  $category_ids = array();
  if($categories)
  foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  $tag_ids = array();
  if($tags)
  foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
  
  $args=array(
    'tax_query' => array(
      'relation' => 'OR',
      array(
        'taxonomy' => 'category',
        'field' => 'id',
        'terms' => $category_ids
      ),
      array(
        'taxonomy' => 'post_tag',
        'field' => 'id',
        'terms' => $tag_ids
      )
    ),
    'post__not_in' => array($post->ID),
    'posts_per_page'=> 4, // Number of related posts that will be shown.
  );
  // query posts
  $my_query = new WP_Query( $args );
  if( $my_query->have_posts() ) {
    echo "<h3>Related posts</h3><ul>";
    while( $my_query->have_posts() ) { $my_query->the_post();
      // display each post
      ?>
      <li><a href='<?php the_permalink(); ?>' rel='canonical'><?php the_title();?></a></li>
      <?php
    }
    echo "</ul>";
  }
}
wp_reset_postdata();
?>

;

public by f8lrebel  5093  1  5  0

Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts: gistfile1.textile
h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)

h2. General

| *⌘T* | go to file |
| *⌘⌃P* | go to project |
| *⌘R* | go to methods |
| *⌃G* | go to line |
| *⌘KB* | toggle side bar |
| *⌘⇧P* | command prompt |
| *⌃ `* | python console |
| *⌘⇧N* | new window (useful for new project) |

h2. Editing

| *⌘L* | select line (repeat select next lines) |
| *⌘D* | select word (repeat select others occurrences in context for multiple editing) |
| *⌃⇧M* | select content into brackets |
| *⌘⇧↩* | insert line before |
| *⌘↩* | inter line after |
| *⌃⇧K* | delete line |
| *⌘KK* | delete from cursor to end of line |
| *⌘K⌫* | delete from cursor to start of line |
| *⌘⇧D* | duplicate line(s) |
| *⌘J* | join lines |
| *⌘KU* | upper case |
| *⌘KL* | lower case |
| *⌘ /* | comment |
| *⌘⌥ /* | block comment |
| *⌘Y* | redo or repeat |
| *⌘⇧V* | past and ident |
| *⌃ space* | autocomplete (repeat to select next suggestion) |
| *⌃M* | jump to matching brackets |
| *⌘U* | soft undo (movement undo) |
| *⌘⇧U* | soft redo (movement redo) |

h2. XML/HTML

| *⌘⇧A* | select content into tag |
| *⌘⌥ .* | close tag |

h2. Find/Replace

| *⌘F* | find |
| *⌘⌥F* | replace |
| *⌘⌥G* | find next occurrence of current word |
| *⌘⌃G* | select all occurrences of current word for multiple editing |
| *⌘⇧F* | find in files |

h2. Splits/Tabs

| *⌘⌥1* | single column |
| *⌘⌥2* | two columns |
| *⌘⌥5* | grid (4 groups) |
| *⌃[1,2,3,4]* | focus group |
| *⌃⇧[1,2,3,4]* | move file to group |
| *⌘[1,2,3...]* | select tab |

h2. Bookmarks

| *⌘F2* | toggle bookmark |
| *F2* | next bookmark |
| *⇧F2* | previous bookmark |
| *⌘⇧F2* | clear bookmarks |

h2. Marks

| *⌘K space* | set mark // ⌘K; for me |
| *⌘KW* | delete from cursor to mark |
| *⌘KA* | select from cursor to mark |
| *⌘KG* | clear mark |


;

public by f8lrebel  2970  0  4  0

A little cutesy command line animation

A little cutesy command line animation: blinky.php
PHP
<?php
  /** 
   * Blinky is a little ASCII animation inspired by
   * Shane Harter's "Progress Display for PHP CLI scripts"
   * see: https://gist.github.com/4211173
   * this one is written by Azi Crawford
   **/

  function draw_blink ($counter){
      $frame = $counter % 12; 
      switch ($frame) {
          case 0:
              echo str_repeat("\010", 50);
              echo str_pad("O.O", 50, ' ', STR_PAD_LEFT);
              break;
          case 1:
              echo str_repeat("\010", 50);
              echo str_pad("O.o", 50, ' ', STR_PAD_LEFT);
              break;
          case 2:
              echo str_repeat("\010", 50);
              echo str_pad("O.-", 50, ' ', STR_PAD_LEFT);
              break;
          case 3:
              echo str_repeat("\010", 50);
              echo str_pad("O.o", 50, ' ', STR_PAD_LEFT);
              break;
          case 4:
              echo str_repeat("\010", 50);
              echo str_pad("O.O", 50, ' ', STR_PAD_LEFT);
              break;
          case 5:
              echo str_repeat("\010", 50);
              echo str_pad("o.O", 50, ' ', STR_PAD_LEFT);
              break;
          case 6:
              echo str_repeat("\010", 50);
              echo str_pad("-.O", 50, ' ', STR_PAD_LEFT);
              break;
          case 7:
              echo str_repeat("\010", 50);
              echo str_pad("o.O", 50, ' ', STR_PAD_LEFT);
              break;
          case 8:
              echo str_repeat("\010", 50);
              echo str_pad("O.O", 50, ' ', STR_PAD_LEFT);
              break;
          case 9:
              echo str_repeat("\010", 50);
              echo str_pad("o.o", 50, ' ', STR_PAD_LEFT);
              break;
          case 10: 
              echo str_repeat("\010", 50);
              echo str_pad("-.-", 50, ' ', STR_PAD_LEFT);
              break;
          case 11:
              echo str_repeat("\010", 50);
              echo str_pad("o.o", 50, ' ', STR_PAD_LEFT);
              break;
        }
      }

echo str_repeat("\n", 10);

for ($i=0; $i<100; $i++) {
  draw_blink($i);
  usleep(125000);
}

echo str_repeat("\010", 50);
echo str_repeat(' ', 50) . PHP_EOL;

;