Skip to content

Instantly share code, notes, and snippets.

View jabranr's full-sized avatar
🚀
Building ideas

Jabran Rafique jabranr

🚀
Building ideas
View GitHub Profile
@jabranr
jabranr / xdebug-sublime-settings-template.json
Created February 3, 2016 09:36
Xdebug Sublime client settings template
{
"folders": [
{
"path": ".",
"follow_symlinks": true
}
],
"settings": {
"xdebug": {
"path_mapping": {
@jabranr
jabranr / setup-sshfs.sh
Last active February 25, 2016 18:28
Set up code tunnel using SSHFS between remote and host
# Mount volumes using SSHFS from a remote
# Author: Jabran Rafique <hello@jabran.me>
# License: MIT License
#!/bin/bash
sshfs {REMOTE}:{PATH} {HOST_PATH} -o follow_symlinks
@jabranr
jabranr / decimal2binary.php
Last active February 25, 2016 18:36
Converts the integer to binary and outputs list of integers that are power of 2 (http://jabran.me/using-special-integers-with-bitwise-operators-for-php-rbac/)
<?php
/**
* Converts the integer to binary and outputs list of integers that are power of 2
*
* @author: Jabran Rafique <hello@jabran.me>
* @param: integer $decimal
* @return: string
*/
function get_special_binary( $decimal ) {
@jabranr
jabranr / javascript-optimization-example.js
Created March 29, 2016 14:01
JavaScript optimization example using console.time
/**
* @link http://adripofjavascript.com
*/
// Example 1
(function(console) {
function factoral(num) {
if (num < 0) throw new Error('Bad input!');
if (num % 1 !== 0) throw new Error('That\'s NaN!');
if (num === 0 || num === 1) return 1;
@jabranr
jabranr / php-get-set.sublime-snippet
Created April 1, 2016 14:47
Autogenerate PHP getters setters
<snippet>
<content><![CDATA[
/**
* Get ${1/(.*)/\u$1/:[ Prop name ]}
* ${4:[description]}
*
* @return ${3:[type]}
*/
public function get${1/(.*)/\u$1/:[ Prop name ]}() {
return \$this->${1:[ Prop name ]};
@jabranr
jabranr / .editorconfig
Created April 26, 2016 08:09
Editor config
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@jabranr
jabranr / sublime_custom_getter_setter.py
Last active June 19, 2016 09:09
Sublime custom template for PHP Getters and Setters package
# Save the file to "{Sublime Packages}/PHP Getters and Setters/user_templates.py"
# Then add following "user config" in Sublime Text:
#
# {
# "registerTemplates" : [ "customTemplate" ],
# "template" : "customTemplate"
# }
#
# Restart Sublime Text
#
@jabranr
jabranr / prepare-commit-msg.sh
Last active June 20, 2016 12:47
PUT a JIRA ticket numebr into commit message
# Save in .git/hooks/prepare-commit-msg
#
# This means that current branch was branched
# out from JIRA/Bitbucket and has a JIRA
# ticket number in its name.
JIRA=$(cat .git/HEAD | grep -Eo "[A-Z]+-[0-9]+")
echo "$JIRA" >> "$1"
@jabranr
jabranr / BaseEntity.php
Last active July 25, 2016 16:10
[POC DRY] BaseEntity class to be used as base for Entities in Symfony2.
<?php
namespace Foo\Bar\Entity;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping as ORM;
/**
* BaseEntity
*
@jabranr
jabranr / toggle-multiple-buttons-with-different-text.js
Last active September 5, 2016 11:58
[jQuery] Toggle multiple buttons at same with different text
$.fn.extend({
disableCta: function() {
this.prop('disabled', true);
// or use your own class
this.addClass('btn--disabled');
// retain current text of the CTA in custom data attribute
// Used html() assuming it is a <button> element
this.attr('data-value', this.html());