Skip to content

Instantly share code, notes, and snippets.

@stresslimit
stresslimit / gist:943745
Created April 27, 2011 05:09
WP order posts by number of facebook likes
<?php
// get fb likes from fb graph api
// put this block in single.php, or somewhere you have $post and have setup postdata [inside a Loop]
$obj = json_decode( file_get_contents( 'http://graph.facebook.com/?id='.get_permalink() ) );
$likes = $obj->shares;
update_post_meta($post->ID, '_fb_likes', $likes, false);
// make a Loop [in a template page or whatever] to query and display posts ordered by fb like popularity
$args = array(
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@madapaja
madapaja / OdmTestCase.php
Created October 20, 2011 07:23
Base testcase class for Doctrine MongoDB ODM testcases
<?php
namespace Madapaja\ODM\MongoDB\Tests;
use Doctrine\ODM\MongoDB\Configuration;
/**
* Base testcase class for MongoDB ODM testcases.
*
* Usage:
@igorw
igorw / silex-php+twig+TwigBrige+translation.php
Created November 5, 2011 11:53 — forked from mTorres/silex-php+twig+TwigBrige+translation.php
Gist Sample to enable Twig + TwigTranslation bridge to Silex
<?php
require_once __DIR__ . '/../lib/vendor/Silex/silex.phar';
$app = new Silex\Application();
$app['debug'] = true;
// Registering Symfony\Yaml and Symfony\Config
$app['autoloader']->registerNamespace('Symfony', __DIR__.'/../lib/vendor/symfony/src');
@oodavid
oodavid / README.md
Last active April 6, 2024 18:45 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@beriberikix
beriberikix / backbone-links.md
Created March 4, 2012 03:45
AWSUM Web Development Linkz
@gyndav
gyndav / .travis.yml
Created April 10, 2012 12:57
Simple Mongo PHP Driver extension installer for Travis CI. Works like a charm for other PECL extensions too.
before_script:
- ./path/to/mongo-php-driver-installer.sh
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@benhosmer
benhosmer / udp-port-scanning.txt
Created April 20, 2012 15:31
UDP Port Troubleshooting using netcat
Using the nc command you can scan a port or a range of ports to verify whether a UDP port is open and able to receive traffic.
This first command will scan all of the UDP ports from 1 to 65535 and add the results to a text file:
$ nc -vnzu server.ip.address.here 1-65535 > udp-scan-results.txt
This merely tells you that the UDP ports are open and receive traffic.
Perhaps a more revealing test would be to actually transfer a file using UDP.
@esmooov
esmooov / ctrr.md
Created May 25, 2012 16:50
Carats and Tildes, Resets and Reverts

Until last night I lived in fear of tildes, carats, resets and reverts in Git. I cargo culted, I destroyed, I laid waste the tidy indicies, branches and trees Git so diligently tried to maintain. Then Zach Holman gave a talk at Paperless Post. It was about Git secrets. He didn't directly cover these topics but he gave an example that made me realize it was time to learn.

A better undo

Generally, when I push out bad code, I panic, hit git reset --hard HEAD^, push and clean up the pieces later. I don't even really know what most of that means. Notational Velocity seems to be fond of it ... in that I just keep copying it from Notational Velocity and pasting it. Turns out, this is dumb. I've irreversibly lost the faulty changes I made. I'll probably even make the same mistakes again. It's like torching your house to get rid of some mice.

Enter Holman. He suggests a better default undo. git reset --soft HEAD^. Says it stag