Skip to content

Instantly share code, notes, and snippets.

View autarch's full-sized avatar

Dave Rolsky autarch

View GitHub Profile
has foo => (
is => 'ro',
lazy => 1,
default => sub { $_[0]->_foo_bar->[0] },
);
has bar => (
is => 'ro',
lazy => 1,
default => sub { $_[0]->_foo_bar->[1] },
@autarch
autarch / gist:5856172
Created June 25, 2013 05:38
Make insane website colors sane - I can't remember where I first found this.
javascript:(function(){function R(w){try{var d=w.document,j,i,t,T,N,b,r=1,C;for(j=0;t=["object","embed","applet","iframe"][j];++j){T=d.getElementsByTagName(t);for(i=T.length-1;(i+1)&&(N=T[i]);--i)if(j!=3||!R((C=N.contentWindow)?C:N.contentDocument.defaultView)){b=d.createElement("div");b.style.width=N.width; b.style.height=N.height;b.innerHTML="<del>"+(j==3?"third-party "+t:t)+"</del>";N.parentNode.replaceChild(b,N);}}}catch(E){r=0}return r}R(self);var i,x;for(i=0;x=frames[i];++i)R(x)})(); javascript:(function(){var newSS, styles='* { background: white ! important; color: black !important; text-shadow: none !important } :link, :link * { color: #0000EE !important } :visited, :visited * { color: #551A8B !important }'; if(document.createStyleSheet) { document.createStyleSheet("javascript:'"+styles+"'"); } else { newSS=document.createElement('link'); newSS.rel='stylesheet'; newSS.href='data:text/css,'+escape(styles); document.getElementsByTagName("head")[0].appendChild(newSS); } })(); javascript:(function(){var d
my $int = uint128(0);
return $int if $size == 0;
my @unpacked = unpack( 'NNNN', $self->_zero_pad_left( $buffer, 16 ) );
for my $piece (@unpacked) {
$int <<= 32;
$int |= $piece;
}
ipv6str = malloc(strlen(ipstr) + 2);
strncat(ipv6str, "::", 2);
strncat(ipv6str, ipstr, strlen(ipstr));
static int lookup(MMDB_root_entry_s * root, const char *ipstr)
{
struct in_addr ip;
struct in6_addr ip6;
int ai_flags = AI_NUMERICHOST|AI_V4MAPPED;
int status;
int depth = root->entry.mmdb->depth;
if (ipstr == NULL) {
DO $$
DECLARE c INTEGER;
BEGIN
SELECT COUNT(*) INTO c FROM pg_type WHERE typname = 'footype';
IF c > 0 THEN
RETURN;
END IF;
CREATE DOMAIN footype AS TEXT CONSTRAINT len CHECK ( length(VALUE) > 1 );
END$$;
<?php
$id = pods_var( 'last', 'url' );
$tag = $GLOBALS['Pods_TAG'] = pods( 'volunteer_opportunity_tag', $id, true );
echo "ID = " . $id . ", TOTAL = " . $tag->total(). ", FOUND = " . $tag->total_found(), ", EXISTS = " . $tag->exists();
$GLOBALS['Pods_TITLE'] = $tag->display('title') . ' Volunteer Opportunity';
<?php
$tag = $GLOBALS['Pods_TAG'];
$id = $tag->field('slug');
$pods = pods('volunteer', array( 'where' => "volunteer_opportunity_tag.slug = '$id'", orderby => 'name ASC'));
if ( $pods->exists() ){
$opp = $pods->title() > 1 ? 'opportunities' : 'opportunity';
$is = $pods->title() > 1 ? 'are' : 'is';
<ul class="exhibitors">
<?php
while ( $obj->fetch() ) :
$exhibitor_url = $obj->field('exhibitor_url', TRUE);
$yelp_url = $obj->field('yelp_url', TRUE);
$vegguide_url = $obj->field('vegguide_url', TRUE);
?>
<li>
<?php
<li>
<a href="/volunteer/category/{@slug}">{@name}</a>
{@description}
</li>