Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@dmolsen
dmolsen / Facebook + Twitter Fan Count
Created September 27, 2010 15:47
Pulls the Facebook fan count and Twitter follower count for the specified accounts.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var f_page = "wvumountaineers"; // the page name for your fan page, e.g. the 'wvumountaineers' part of http://facebook.com/wvumountaineers
var t_page = "westvirginiau"; // the account name for your main twitter account
function add_commas(number) {
if (number.length > 3) {
var mod = number.length % 3;
@rmanalan
rmanalan / $w.js
Created October 5, 2010 23:51
Illustration of a jQuery like object
var $w = function(){
var $w = function(){
return new $w.init;
}
$w.prototype = {
// add all of the methods/props you want accessible as $w().method() or $w().prop here:
init: function(){
console.log('init called');
},
@cowboy
cowboy / github_post_recieve.php
Created October 11, 2010 02:04
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi
@jeremeamia
jeremeamia / gist:633632
Created October 19, 2010 04:51
PHP is so weird
<?php // Some lovely, valid php code that prints "foofoo"
echo${${($f='f').(${$o='o'}).${$o}}=${$f}.$${$$o}.$$${$$$o}};
echo$$$$$$$$$$$$$$$$$$$$${(${(${(${(${(${($$$foo)})})})})})};
@jakebellacera
jakebellacera / ICS.php
Last active May 25, 2024 19:17
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@jamalsa
jamalsa / gist:660704
Created November 3, 2010 02:14
Use YQL to get title and description from website
<?php
// Set root url, which point to yahoo api
$root = 'http://query.yahooapis.com/v1/public/yql?format=json&diagnostics=true&callback=cbfunc';
// Get title from google
$titleUrl = $root . '&q=' . urlencode("select content from html where url = 'http://google.com' and xpath = '//title'");
// Get description from google
$descUrl = $root . '&q=' . urlencode("select content from html where url='http://google.com' and xpath = '//meta' and name='description'");
// Process it
@flesch
flesch / router.php
Created December 3, 2010 03:49
Simple PHP router.
<?php
/*******************************************************************************
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
*******************************************************************************/
@CHH
CHH / function_currying.php
Created December 6, 2010 12:10
Prefill the arguments of functions (Currying)
<?php
function func_curry($fn)
{
$args = array_slice(func_get_args(), 1);
return function() use ($fn, $args) {
$args = array_merge($args, func_get_args());
return call_user_func_array($fn, $args);
};
<?php
// pipes each function's return value as input into the next function in the chain
function func_compose()
{
$fns = func_get_args();
$composition = function() use ($fns) {
$input = func_get_args();
foreach ($fns as $fn) {
$return = call_user_func_array($fn, $input);
@ryanb
ryanb / github_tree_slider.js
Created December 6, 2010 17:23
This is how GitHub's new AJAX file browser works.
GitHub.TreeSlider = function () {
if (window.history && window.history.pushState) {
function a() {
if (e.sliding) {
e.sliding = false;
$(".frame-right").hide();
$(".frame-loading:visible").removeClass("frame-loading")
}
}
if (!($("#slider").length == 0 || !GitHub.shouldSlide)) if (!navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {