Skip to content

Instantly share code, notes, and snippets.

View ahmednuaman's full-sized avatar
💭
I'm hiring! https://firemind.io/careers

Ahmed Nuaman ahmednuaman

💭
I'm hiring! https://firemind.io/careers
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / storage.js
Created July 17, 2012 14:43
A localStorage wrapper for HTML5 and shit
var Storage = function(name, callback)
{
var cache = { };
var keysIndex = '_' + name + '_';
var write = true;
// let's cache!
function _get(key)
{
var data = _.clone( cache[ key ] );
@ahmednuaman
ahmednuaman / deploy.sh
Created November 26, 2012 15:19
SVN to FTP
#!/usr/bin/env bash
DIR='tmp'
REMOTE='your_app'
echo 'Making tmp dir'
if [[ -d "$DIR" ]]; then
rm -rf $DIR
fi
echo 'Exporting SVN to tmp'
String.prototype.linkify = function()
{
var str = this.toString();
str = str.replace(/(https?:\/\/[^\s]+)/gim, '<a href="$1">$1</a>', str);
str = str.replace(/([#|@][^\s]+)/gim, '<a href="http://twitter.com/$1">$1</a>', str);
return str;
}
@ahmednuaman
ahmednuaman / Dockerfile
Created October 16, 2015 11:13
Magento Dockerfile
FROM octohost/base:trusty
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys C300EE8C; \
echo 'deb http://ppa.launchpad.net/nginx/stable/ubuntu trusty main' > /etc/apt/sources.list.d/nginx-stable-trusty.list; \
apt-get update; \
apt-get install -y nginx git
ADD /tmp-conf/default /etc/nginx/sites-available/default
ADD /tmp-conf/nginx.conf /etc/nginx/nginx.conf
Verifying that +ahmednuaman is my blockchain ID. https://onename.com/ahmednuaman