Skip to content

Instantly share code, notes, and snippets.

View furkanmustafa's full-sized avatar
💭
Set your status

Furkan Mustafa furkanmustafa

💭
Set your status
View GitHub Profile
@furkanmustafa
furkanmustafa / nonBreakingExplode.php
Created July 20, 2013 14:08
Replacement for php's built-in explode function, doesn't break quotes, etc.
<?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 July 20, 2013 14:27
Shell script to be used in build phases in xCode, so it will inject git revision and stuff into bundle
#!/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
//
// 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 November 30, 2013 19:26
NSString Categories for localization, formatting, regex
//
// 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 December 18, 2013 11:42
NSString category for formatting numbers easily with optional NSNumberFormatter settings as block
// 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 November 27, 2012 10:44
php script for parsing html element attributes
<?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 February 10, 2016 03:38
Sample Asynchronous action code for rails
# 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 April 22, 2016 09:39
Quickly start an iso with qemu (kvm)
#!/bin/sh -e
exec qemu-system-x86_64 -enable-kvm -cdrom $1 -m 1024
@furkanmustafa
furkanmustafa / rancher.sh
Last active August 3, 2016 09:19
A draft rancher management script using bash and jshon
#!/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)
@furkanmustafa
furkanmustafa / .tmux.conf
Created December 14, 2016 01:51
Tmux Configuration
set -g default-terminal "screen-256color"
#set -g history-limit 10000
#set -g mode-mouse on
#set -g terminal-overrides 'xterm*:smcup@:rmcup@'
#set -g mouse-select-pane on
#set -g mouse-select-window on
#set -g mouse-resize-pane on
bind -n WheelUpPane copy-mode
bind -n S-down new-window