Skip to content

Instantly share code, notes, and snippets.

💭
Set your status

Furkan Mustafa furkanmustafa

View GitHub Profile
@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 / html-php-date-picker.php
Created Jan 27, 2013
Date Picker Select Generator for HTML & PHP
View html-php-date-picker.php
<select name="year">
<option value="">Year</option>
<?php for ($year = date('Y'); $year > date('Y')-100; $year--) { ?>
<option value="<?php echo $year; ?>"><?php echo $year; ?></option>
<?php } ?>
</select>
<select name="month">
<option value="">Month</option>
<?php for ($month = 1; $month <= 12; $month++) { ?>
<option value="<?php echo strlen($month)==1 ? '0'.$month : $month; ?>"><?php echo strlen($month)==1 ? '0'.$month : $month; ?></option>
@furkanmustafa
furkanmustafa / vmstat-parser.php
Created Feb 7, 2013
PHP Function for parsing vmstat output
View vmstat-parser.php
<?php
// TEST
// $res[] = "procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----";
// $res[] = " r b swpd free buff cache si so bi bo in cs us sy id wa";
// $res[] = " 0 0 0 10376 148188 291056 0 0 4 29 85 9 1 0 98 1";
// // or
// // exec('vmstat', $res);
// print_r(parseVMStatOutput($res));
@furkanmustafa
furkanmustafa / php-query-string.php
Last active Dec 14, 2015
PHP Functions for parsing & building query strings, in a better way than http_build_query or parse_str does.
View php-query-string.php
<?php
function ParseQueryString($query, $orig = false) {
$items = $orig ? $orig : array();
$_items = explode('&', $query);
foreach ($_items as $item) {
if (strpos($item, '=')===false) {
$items[urldecode($item)] = true;
}
else {
@furkanmustafa
furkanmustafa / onMainQueue.mm
Last active Dec 17, 2015
simple function for running UI Updates (or anything) on main thread for Cocoa. Can be useful if you have a callback you are not sure it always runs on main thread.
View onMainQueue.mm
void onMainQueue(void(^block)(void)) {
if ([NSThread isMainThread])
block();
else
dispatch_sync(dispatch_get_main_queue(), block);
}
//usage example:
- (void)callbackThatIDontKnowWhichThreadIsItRunningOn {
onMainQueue(^{
@furkanmustafa
furkanmustafa / putio.sh
Last active Jul 4, 2017
Simple Bash Script to download files from your put.io accountUsage: putio.sh "https://put-io-download-link"
View putio.sh
#!/bin/bash
PUTIO_USERNAME="your put.io username"
PUTIO_PASSWORD="your put.io password"
wget --http-user=${PUTIO_USERNAME} --http-password=${PUTIO_PASSWORD} --content-disposition -c $@
@furkanmustafa
furkanmustafa / FMConfigurationManager.php
Last active Dec 17, 2015
Simple JSON Configuration Manager
View FMConfigurationManager.php
<?php
/**
* A Simple JSON Site-wide Configuration manager with key-path access, overriding, inline variables, etc..
* It might look ugly for some people, most important goal with this is simplicity in the code that uses this.
*
* You can find usage sample at the end of the file
*
* @author Furkan Mustafa <furkan@fume.jp>
* @version 0.1.3
@furkanmustafa
furkanmustafa / NSBaseConversion.mm
Created May 28, 2013
Objective-C Base Conversion
View NSBaseConversion.mm
/**
Original Code From, Md. Mahmud Ahsan, http://thinkdiff.net/mixed/base-conversion-handle-upto-36-bases/, 2008.02.28
Adapted Objective-C, Furkan Mustafa, 2013.05.28
Description: Alpha Numeric Base Conversion, Handles upto base 36
*/
NSString* reverseString(NSString* original) {
const char* chars = [original cStringUsingEncoding:NSASCIIStringEncoding];
int length = strlen(chars);
char* new = (char*)malloc(length+1);
@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();
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.