Skip to content

Instantly share code, notes, and snippets.

💭
Set your status

Furkan Mustafa furkanmustafa

💭
Set your status
Block or report user

Report or block furkanmustafa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@furkanmustafa
furkanmustafa / mem.class.php
Last active Dec 17, 2015
Easy to use memcache proxy class for php
View mem.class.php
<?php
/*
Memcache Proxy Class for data
Furkan Mustafa, 2013.05
use it.
usage:
$dataUsedTooMuch = mem::cache('myhandle', 30, function() {
return db::query('SELECT CRAZY SLOW SQL SCRIPT');
@furkanmustafa
furkanmustafa / nonBreakingExplode.php
Created Jul 20, 2013
Replacement for php's built-in explode function, doesn't break quotes, etc.
View nonBreakingExplode.php
<?php
// a replacement for php's built-in explode function, doesn't break quotes, etc.
function nonBreakingExplode($delimiter, $string, $nobreakChars = array('"', '\'', '()', '[]')) {
$pos = 0;
$len = strlen($string);
$delimiterLen = strlen($delimiter);
$lastCut = 0;
$nest = array();
@furkanmustafa
furkanmustafa / xCodeGitRevision.sh
Created Jul 20, 2013
Shell script to be used in build phases in xCode, so it will inject git revision and stuff into bundle
View xCodeGitRevision.sh
#!/bin/bash
BUILD_NUMBER=`git rev-parse --short HEAD`
git update-index -q --refresh
CHANGES=$(git diff-index --name-only HEAD --)
if [ ! -z "${CHANGES}" ]; then
BUILD_NUMBER="${BUILD_NUMBER}+"
if [ "${CONFIGURATION}" == "Debug" ]; then
git diff --color | tools/ansi2html.sh --bg=dark > gitdiff.html
cp ${PROJECT_DIR}/gitdiff.html ${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}
fi
View UIImage+Retina4.h
//
// UIImage+Retina4.h
// StunOMatic
//
// Created by Benjamin Stahlhood on 9/12/12.
// Copyright (c) 2012 DS Media Labs. All rights reserved.
//
#import <UIKit/UIKit.h>
@furkanmustafa
furkanmustafa / NSString+FMAdditions.h
Created Nov 30, 2013
NSString Categories for localization, formatting, regex
View NSString+FMAdditions.h
//
// NSString+FMAdditions.h
// Use it. maybe keep a link to the author or sth.
//
#import <Foundation/Foundation.h>
// StringWithFormat Shorthand
#define f(format, ...) [NSString stringWithFormat:(format), ##__VA_ARGS__]
@furkanmustafa
furkanmustafa / NSString+FMNumberFormatter.m
Created Dec 18, 2013
NSString category for formatting numbers easily with optional NSNumberFormatter settings as block
View NSString+FMNumberFormatter.m
// use it. get rid of `autorelease` if using arc.
//
// .h file
@interface NSString (FMNumberFormatter)
+ (NSString *)stringByFormattingNumber:(NSNumber*)number
formatterSettings:(void(^)(NSNumberFormatter* formatter))settingsBlock;
@end
@furkanmustafa
furkanmustafa / php-html-attr-parser.php
Created Nov 27, 2012
php script for parsing html element attributes
View php-html-attr-parser.php
<?php
// TEST
//print_r(getTagAttributes('<img enabled href=/fuck/my/attr/syntax" disabled id="idofmyelemtnt" title="Incredible Web Site" src="/images/incredibility.jpg" style="height:300px;width:900px;" />'));
function getTagAttributes($htmlortag, $name = false) { // name=false returns all attributes as array
$p = 0;
$tag = false;
$inquote = false;
$started = false;
@furkanmustafa
furkanmustafa / async_controller.rb
Last active Feb 10, 2016
Sample Asynchronous action code for rails
View async_controller.rb
# FROM: http://www.jonb.org/2013/01/25/async-rails.html @jbaudanza
# Modified to get it working.
module AsyncController
# This is the rack endpoint that will be invoked asyncronously. It will be
# wrapped in all the middleware that a normal Rails endpoint would have.
class RackEndpoint
attr_accessor :action
@furkanmustafa
furkanmustafa / start-iso-vm.sh
Created Apr 22, 2016
Quickly start an iso with qemu (kvm)
View start-iso-vm.sh
#!/bin/sh -e
exec qemu-system-x86_64 -enable-kvm -cdrom $1 -m 1024
@furkanmustafa
furkanmustafa / rancher.sh
Last active Aug 3, 2016
A draft rancher management script using bash and jshon
View rancher.sh
#!/bin/sh -e
# set -x
RANCHER_URL="rancher.mydomain.com"
PROJECT_ID="1a5" #id of my stack in rancher
CATTLE_ACCESS_KEY=MY_RANCHER_ACCESS_KEY
CATTLE_SECRET_KEY=MY_RANCHER_ACCESS_SECRET
TMP_FILE=$(mktemp)
You can’t perform that action at this time.