Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar

Hazem Noor HazemNoor

View GitHub Profile
@itakeahike
itakeahike / EditGrid.js
Last active July 13, 2016 22:58
ExtJS 4.2: Add/remove custom filter for grid store using a checkbox on the toolbar (local filtering)
(1) Define the custom filter
me.approvedFilter = Ext.create('Ext.util.Filter', {
id: 'approvedFilter',
filterFn: function (record) {
return !record.data.approved;
}
});
(2) In the grid panel, define the checkbox in the toolbar
@lemiorhan
lemiorhan / post-receive
Last active February 8, 2023 10:06
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
@davidpaulsson
davidpaulsson / wp-get_id_by_slug
Created February 26, 2014 06:20
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
@emad-elsaid
emad-elsaid / ruby-analytics.rb
Last active August 29, 2015 13:56
Project files analytics script, could work even on PHP, python projects ;)
directory = ARGV.shift || Dir.pwd
$dont_get_into = ['.','..']
$allowed = {
'Ruby' => '.rb',
'Ruby HTML Templates' => '.html.erb',
'YAML' => '.yml',
'RDoc' => '.rdoc',
'HTML' => '.html',
'Javascript' => '.js',
'CSS' => '.css',
@emad-elsaid
emad-elsaid / post2fb.rb
Created March 3, 2014 11:37
posting to facebook groups all at once with ruby posting to facebook groups all at once with ruby
#!/usr/bin/env ruby
require 'koala' # gem install koala --no-ri --no-rdoc
# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "groups", "photos" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
group_filtering_words = ['ruby']
image_path = 'image.png' #change to your image path
message = 'My Cool image.' # your message
@salcode
salcode / .gitignore
Last active February 10, 2024 10:56
See https://salferrarello.com/wordpress-gitignore/ for the latest version of my WordPress .gitignore file
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@Ellrion
Ellrion / php-restrictions.nginxconf
Last active June 5, 2024 12:36
Nginx + Php-fpm config for Laravel app
# /etc/nginx/global/php-restrictions.conf
# Don't throw any errors for missing favicons and don't display them in the logs
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Don't log missing robots or show them in the nginx logs
location = /robots.txt {
allow all;
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active May 23, 2024 12:17
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@fballiano
fballiano / subscribeEmails.php
Created June 20, 2014 10:22
Import newsletter subscribers (without sending any emails) into Magento
<?php
$store_id = 5;
$csv_filepath = "newsletter.csv";
$email_csv_column_index = 2;
$csv_delimiter = ',';
$csv_enclosure = '"';
$magento_path = __DIR__;
require "{$magento_path}/app/Mage.php";
@fballiano
fballiano / load_collection.php
Last active January 21, 2018 11:17
Magento product collections, general loading
<?php
$store_id = Mage::app()->getStore()->getId();
$collection = Mage::getModel("catalog/product")->getCollection();
$collection->setStoreId($store_id);
$collection->addStoreFilter($store_id);
//$collection->addAttributeToSelect("*");
$collection->addAttributeToFilter('status', array('in' => array(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)));
$collection->addAttributeToFilter('visibility', array('in '=> array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
Mage::getSingleton("cataloginventory/stock")->addInStockFilterToCollection($collection);