Skip to content

Instantly share code, notes, and snippets.

View ahmednuaman's full-sized avatar
🏴‍☠️

Ahmed Nuaman ahmednuaman

🏴‍☠️
View GitHub Profile
@ahmednuaman
ahmednuaman / pref.py
Created June 15, 2012 10:41
Python string in vs index vs find
#!/usr/bin/env python
import profile
LIST = ['ass','ass lick','asses','asshole','assholes','asskisser','asswipe','balls','bastard','beastial','beastiality','beastility','beaver','belly whacker','bestial','bestiality','bitch','bitcher','bitchers','bitches','bitchin','bitching','blow job','blowjob','blowjobs','bonehead','boner','brown eye','browneye','browntown','bucket cunt','bull shit','bullshit','bum','bung hole','butch','butt','butt breath','butt fucker','butt hair','buttface','buttfuck','buttfucker','butthead','butthole','buttpicker','chink','circle jerk','clam','clit','cobia','cock','cocks','cocksuck','cocksucked','cocksucker','cocksucking','cocksucks','cooter','crap','cum','cummer','cumming','cums','cumshot','cunilingus','cunillingus','cunnilingus','cunt','cuntlick','cuntlicker','cuntlicking','cunts','cyberfuc','cyberfuck','cyberfucked','cyberfucker','cyberfuckers','cyberfucking','damn','dick','dike','dildo','dildos','dink','dinks','dipshit','dong','douche bag','dumbass','dyke','ejaculate','ejaculated'
@ahmednuaman
ahmednuaman / pagination_query_posts.php
Created January 9, 2012 09:21
Pagination for query_posts
$m = $wp_query->max_num_pages;
if ( $m > 1 )
{
?>
<div class="pagination">
<ul>
<?php for ( $i = 1; $i <= $m; $i++ ): ?>
<li>
<a href="<?php the_permalink(); ?>/page/<?php echo $i; ?>" title="Go to page <?php echo $i; ?>">
@ahmednuaman
ahmednuaman / gist:1505542
Created December 21, 2011 10:30
Response to "why I code"
It works both ways. If designers understood the shit developers have to go through when they send them >1GB PSDs with badly named layers and multiplies everywhere and if developers understood why designers want that button moved by 3px we'd live in a better world.
A designer doesn't need to know how to code as such but understand how the development process works (if they can good well, that's always a bonus) and a developer needs to understand the design process too (if they can use photoshop and edit the PSDs then we're going well).
The fact of the matter is that in this day and age it's less about being a master of one trade or a jack of all, but having a good understanding how different factors from design, development and even sysadmin, come together to make a digital "product". It's that key understanding that means that the players in the different verticals will respect each others comments and decisions.
@ahmednuaman
ahmednuaman / animateCSS.js
Created December 7, 2011 14:38
jQuery plugin to dynamically apply animate.css animations
(function ($) {
$.fn.animateCSS = function (effect, delay, callback) {
// Return this to maintain chainability
return this.each(function () {
// Cache $(this) for speed
var $this = $(this);
@ahmednuaman
ahmednuaman / css_animation_util.py
Created November 30, 2011 19:12
A little utility to take the pain out of writing vendor prefixed CSS3 animations
a = [ 'webkit', 'moz', 'ms', 'o', '' ]
n = 'enter'
f = {
'from' : [
'opacity: 0',
'.transform( e(\'rotate(360deg)\')'
],
'to' : [
'opacity: 1',
@ahmednuaman
ahmednuaman / title_case.php
Created October 19, 2011 09:57
Convert strings to title case
function title_case($string, $delimiters = array(" ", "-", "O'"), $exceptions = array("to", "a", "the", "of", "by", "and", "with", 'it', 'as', "for")) {
/*
* Exceptions in lower case are words you don't want converted
* Exceptions all in upper case are any words you don't want converted to title case
* but should be converted to upper case, e.g.:
* king henry viii or king henry Viii should be King Henry VIII
*/
foreach ($delimiters as $delimiter){
$words = explode($delimiter, $string);
$newwords = array();
@ahmednuaman
ahmednuaman / serialise.py
Created April 28, 2011 15:14
Prepare a GAE model for serialisation
#!/usr/bin/env python
import logging
import urllib
def serialise_model(m, d):
# let's serialise this bad boy
ps = m.properties()
# check if we're dealing with a list or not
@ahmednuaman
ahmednuaman / get_touch_coords.js
Created March 31, 2011 11:25
This converts touch events list to a single coors x,y object
function scrollGetCoords(e)
{
var coors;
if ( e.hasOwnProperty( 'originalEvent' ) )
{
e = e.originalEvent;
}
if ( e.touches && e.touches.length )
@ahmednuaman
ahmednuaman / detect_if_dom_is_ready.js
Created March 8, 2011 16:52
Using document.readyState to see if the DOM is ready
var timer = setInterval( function()
{
if ( /loaded|complete/.test( document.readyState ) )
{
clearInterval( timer );
// go!
}
}, 10 );
@ahmednuaman
ahmednuaman / wordpress-multisite-lighttpd.conf
Created December 12, 2010 21:52
A nice little rewrite directive for WordPress Multi-site and Lighttpd
url.rewrite-once = (
"^/(.*/)?files/$" => "/index.php",
"^/(.*/)?files/(.*)" => "/wp-content/blogs.php?file=$2",
"^(/wp-admin/.*)" => "$1",
"^/([_0-9a-zA-Z-]+/)?(wp-.*)" => "/$2",
"^/([_0-9a-zA-Z-]+/)?(.*\.php)" => "/$2",
"^/(.*)/?$" => "/index.php"
)