Skip to content

Instantly share code, notes, and snippets.

🚀
Building ideas

Jabran Rafique⚡️ jabranr

🚀
Building ideas
View GitHub Profile
@jabranr
jabranr / toggle-multiple-buttons-with-different-text.js
Last active Sep 5, 2016
[jQuery] Toggle multiple buttons at same with different text
View toggle-multiple-buttons-with-different-text.js
$.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());
@jabranr
jabranr / BaseEntity.php
Last active Jul 25, 2016
[POC DRY] BaseEntity class to be used as base for Entities in Symfony2.
View BaseEntity.php
<?php
namespace Foo\Bar\Entity;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping as ORM;
/**
* BaseEntity
*
@jabranr
jabranr / prepare-commit-msg.sh
Last active Jun 20, 2016
PUT a JIRA ticket numebr into commit message
View prepare-commit-msg.sh
# 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 / sublime_custom_getter_setter.py
Last active Jun 19, 2016
Sublime custom template for PHP Getters and Setters package
View sublime_custom_getter_setter.py
# 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
#
View .editorconfig
# 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 / mysql_backup_cron.sh
Last active Jun 19, 2020
Automatic MySQL dump and backup to Git repo cron job
View mysql_backup_cron.sh
#!/bin/sh
#
# @author: Jabran Rafique <hello@jabran.me>
# @link: http://jabran.me/articles/automatic-database-backup-using-git-hosting/
# Set variables
FULLDATE = $(date +"%Y-%d-%m %H:%M")
NOW = $(date +"%Y-%m-%d-%H-%M")
MYSQL_DUMP = `which mysqldump`
GIT = `which git`
@jabranr
jabranr / php-get-set.sublime-snippet
Created Apr 1, 2016
Autogenerate PHP getters setters
View php-get-set.sublime-snippet
<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 / javascript-optimization-example.js
Created Mar 29, 2016
JavaScript optimization example using console.time
View javascript-optimization-example.js
/**
* @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 / git-helpers.sh
Last active Dec 9, 2016
Git helpers commands
View git-helpers.sh
# Get own stats for the day
git diff --shortstat "@{0 day ago}"
# Get contributor stats
git shortlog -sn
@jabranr
jabranr / xdebug-sublime-settings-template.json
Created Feb 3, 2016
Xdebug Sublime client settings template
View xdebug-sublime-settings-template.json
{
"folders": [
{
"path": ".",
"follow_symlinks": true
}
],
"settings": {
"xdebug": {
"path_mapping": {
You can’t perform that action at this time.