Skip to content

Instantly share code, notes, and snippets.

View hanigamal's full-sized avatar
🎯
Focusing at office

Hani Gamal hanigamal

🎯
Focusing at office
View GitHub Profile
@hanigamal
hanigamal / gist:4439949
Created January 3, 2013 01:04
Assembla API
<?php
require_once('assembla.plugin');
$key = '...'; //this is your assembla space id
$username = '...'; //this is an assembla user account name
$password = '...'; //this is the password for the above user
$A = new Assembla($key, $username, $password);
//$tickets = $A->listTickets();
@hanigamal
hanigamal / gist:4439957
Last active August 25, 2017 02:47
Validate Credit Cards
#!/usr/local/bin/perl
#
# CC-Verify script for Visa, MasterCard, Amex and Novus Cards
# Written 29 June 1996 by Spider ([email protected])
# http://w3works.com
# http://www.servtech.com/public/spider
#
# Loosely based on a re-post of original by Melvyn Myers
# (initial author unknown) but this revision covers all 13,
# 15 and 16 digit cards using the Mod 10 algorithm.
@hanigamal
hanigamal / gist:4439967
Created January 3, 2013 01:11
Mikrotik Script: Webserver behind NAT
/ip firewall
dst-nat protocol=tcp dst-port=80 Action dst-nat to-address=20.20.20.45 to-ports=80
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=80 protocol=tcp to-addresses=20.20.20.45 to-ports=80
#Creating pppoe interface and ADSL internet connection
/ interface pppoe-client
add name="pppoe-out1" max-mtu=1480 max-mru=1480 interface=ether5 \
user="USERNAMEl" password="PASSWORD" profile=default \
import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.preference.PreferenceManager;
public final class AccountUtils {
@hanigamal
hanigamal / TwitterExport.php
Created March 1, 2013 23:34
Allow the export of complete user time-lines from the twitter service. It joins together all pages of status updates into one large XML block that can then be reformatted/processed with other tools.
<?php
/**
* This script will allow the export of complete user time-lines from the twitter
* service. It joins together all pages of status updates into one large XML block
* that can then be reformatted/processed with other tools.
*
* @since 10/13/08
*
* @copyright Copyright © 2008, Adam Franco
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
// Generated on: 2012-04-13 23:44:46 GMT+00:00
// ************** Tweet 1 of 47455 **************
{
"in_reply_to_screen_name": null,
@hanigamal
hanigamal / gist:5786872
Created June 15, 2013 04:15
jQuery match a text attribute that does not exist
//You're trying to match a text attribute that does not exist. You cannot write:
$("#Select0 option[text='" + myText + "']").get(0).selected = true;
You can use filter() instead:
$("#Select0 option").filter(function() {
return $(this).text() == myText;
}).get(0).selected = true;
//Or, taking more advantage of the library:
@hanigamal
hanigamal / gist:5787987
Created June 15, 2013 12:37
jquery simple math
(function ($) {
'use strict';
$.fn.math = function (operation, a, b) {
return this.each(function () {
var result = 0;
switch(operation){
case '+':
result = a + b;
break;
@hanigamal
hanigamal / gist:5788011
Created June 15, 2013 12:45
jquery record
if (jQuery)
(function(jQuery){
jQuery.extend(jQuery.fn, {
record: function(options){
jQuery(this).each(function(){
var settings = jQuery.extend({
}, options);
var _this = $(this);
load(_this, true);
_this.on('blur change', function() {
@hanigamal
hanigamal / gist:5788020
Last active December 18, 2015 13:09
jquery functions for record
function load(_this, init){
var name = generateName(_this);
var type = _this.attr('type');
if(!type)
type = _this.prop("tagName");
if(!init && type != 'radio' && type != 'checkbox')
localStorage.setItem(name, _this.val())