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 / collectionOrder.js
Last active August 29, 2015 13:57
Simple routines for ordering database data in javascript
var collectionOrder = function(options) {
this.itemCount = options.itemCount;
this.move = options.move;
this.fetch = options.fetch;
if (typeof options.batchMove !== "undefined") {
this.batchMove = options.batchMove;
} else {
this.batchMove = this._batchMoveInternal;
}
};
@furkanmustafa
furkanmustafa / timezone_stack.php
Last active August 29, 2015 14:01
Easy push/pop default timezone stack for php
<?php
// Timezone Stack https://gist.github.com/furkanmustafa/8710c43ba8299ca10a32
class TimezoneStack {
public static $stack = [];
static function Init() {
self::$stack[] = @date_default_timezone_get();
}
@furkanmustafa
furkanmustafa / .tmux.conf
Created October 11, 2014 03:47
Tmux configuration
#### COLOUR (Solarized 256)
# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
@furkanmustafa
furkanmustafa / better-pmset-values
Created July 28, 2015 23:47
Better pmset values
DestroyFVKeyOnStandby 1
Active Profiles:
Battery Power -1*
AC Power -1
Currently in use:
standbydelay 0
standby 0
halfdim 1
hibernatefile /var/vm/sleepimage
darkwakes 0
@furkanmustafa
furkanmustafa / gitcommit.nanorc
Created July 28, 2015 23:51
Git Commit nanorc file with diff/patch support
# Some parts from here : http://milianw.de/code-snippets/git-commit-message-highlighting-in-nano
# Some parts from here : https://github.com/serialhex/nano-highlight/blob/master/patch.nanorc
# syntax highlighting for git commit messages
syntax "patch" ".git/COMMIT_EDITMSG$"
# overlong lines
# color brightred "^.{70,}.+$"
# comment
@furkanmustafa
furkanmustafa / iwscan.py
Created May 28, 2014 04:17
iwlist scan parser for python
#!/usr/bin/env python
# Based on http://ubuntuforums.org/showthread.php?t=984492&p=6193749#post6193749
import subprocess
import re
proc = subprocess.Popen('iwlist scan 2>/dev/null', shell=True, stdout=subprocess.PIPE, )
stdout_str = proc.communicate()[0]
stdout_list = stdout_str.split('\n')
@furkanmustafa
furkanmustafa / php-query-string.php
Last active December 14, 2015 22:39
PHP Functions for parsing & building query strings, in a better way than http_build_query or parse_str does.
<?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 December 17, 2015 04:48
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.
void onMainQueue(void(^block)(void)) {
if ([NSThread isMainThread])
block();
else
dispatch_sync(dispatch_get_main_queue(), block);
}
//usage example:
- (void)callbackThatIDontKnowWhichThreadIsItRunningOn {
onMainQueue(^{
@furkanmustafa
furkanmustafa / FMConfigurationManager.php
Last active December 17, 2015 12:09
Simple JSON Configuration Manager
<?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 / mem.class.php
Last active December 17, 2015 19:29
Easy to use memcache proxy class for 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');