Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar

Hazem Noor HazemNoor

View GitHub Profile
@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
@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',
@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;
}
@lemiorhan
lemiorhan / post-receive
Last active April 12, 2025 19:13
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
@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
@paulund
paulund / cache-pages-with-php.php
Created June 25, 2013 18:27
Here is a quick code snippet which will allow you to easily cache pages in PHP.
<?php
//cache file
$cachefile = 'cached/'.date('M-d-Y').'.php';
//Total time the file will be cached in seconds set to 10 hours
$cachetime = 36000;
//If the cache file already exists and the cache file is over 10hours old then display the cache file
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
include($cachefile);
@msg555
msg555 / gangnam.py
Created January 27, 2013 21:21
Create plots from discrete set of points. It's set to connect the first and last point together, currently.
#!/usr/bin/python
#
# Example usage
# $ ./gangnam.py | gnuplot
# 9
# 0 0
# 1 1
# 2 2
# 0 2
# 1 1
@tawfekov
tawfekov / generator.php
Last active July 6, 2025 02:46
Doctrine2 Generate Entities form Existing Database
<?php
include '../vendor/autoload.php';
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();
// config
$config = new \Doctrine\ORM\Configuration();
@Kevinlearynet
Kevinlearynet / Popular Posts This Month
Created October 8, 2012 13:52
Popular Posts Tracking
@xeoncross
xeoncross / index.php
Created March 8, 2012 17:31
Tiny, SMTP client in PHP
<?php
/*
This is a very tiny proof-of-concept SMTP client. Currently it's over 320 characters (if the var names are compressed). Think you can build one smaller?
*/
ini_set('default_socket_timeout', 3);
$user = '[email protected]';
$pass = '';
$host = 'ssl://smtp.gmail.com';