Skip to content

Instantly share code, notes, and snippets.

View sarfraznawaz2005's full-sized avatar
🏠
Working from home

Sarfraz Ahmed sarfraznawaz2005

🏠
Working from home
View GitHub Profile
@sarfraznawaz2005
sarfraznawaz2005 / table.php
Created September 8, 2017 06:44
creates textual table of given array
<?php
function table($data)
{
$output = [];
foreach ($data as $heading => $array) {
foreach ($array as $key => $value) {
$output[$key][$heading] = $value;
}
@sarfraznawaz2005
sarfraznawaz2005 / import_remote_db.sh
Created October 19, 2016 11:59
Import Remote DB into Local one
#!/bin/bash
# Import Live Database
#
# This bash script will import the live catalog database into your local catalog db.
# You can choose to only dump the table structure, all the data,
# or you can specify exactly which tables you wish to import.
#
# Simply run `bash import-live-db.sh` and you will be prompted with what to do
#
@sarfraznawaz2005
sarfraznawaz2005 / url_encode_decode.php
Created October 19, 2016 08:46
Safe Url encode decode functions
<?php
function base64_url_encode($input)
{
return strtr(base64_encode($input), '+/=', '-_,');
}
function base64_url_decode($input)
{
return base64_decode(strtr($input, '-_,', '+/='));
@sarfraznawaz2005
sarfraznawaz2005 / readability.js
Created June 29, 2016 16:45 — forked from jakedahn/readability.js
Readability.js
/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */
var dbg = (typeof console !== 'undefined') ? function(s) {
console.log("Readability: " + s);
} : function() {};
/*
* Readability. An Arc90 Lab Experiment.
* Website: http://lab.arc90.com/experiments/readability
@sarfraznawaz2005
sarfraznawaz2005 / README.md
Created May 6, 2016 10:38 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@sarfraznawaz2005
sarfraznawaz2005 / csv-export.sh
Created May 1, 2016 09:53 — forked from bxt/csv-export.sh
Exporting whole MySQL databse to CSV files
#!/bin/bash
# USAGE: Will create a .tar.gz with CSVs of all tables in schema.
# Configure below and run as root (i.e. the user mysql runs as)
#
# The script will (or should) SELECT * INTO OUTFILE your tables
# and save them into csv files under /tmp dir first, then name them
# like the tables and move them thogether into a directory. Then
# it will tar everything together and chown you the tarball.
# Schema to export:
@sarfraznawaz2005
sarfraznawaz2005 / interviewitems.MD
Created January 27, 2016 10:42 — forked from amaxwell01/interviewitems.MD
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
@sarfraznawaz2005
sarfraznawaz2005 / hours_till_today.php
Last active January 29, 2016 06:24
hours till today
<?php
date_default_timezone_set('Asia/Karachi');
#################################################################
$leaves = 0; // edit this if needed
#################################################################
$hours = 8;
$workdays = array();
@sarfraznawaz2005
sarfraznawaz2005 / total_hours.php
Last active January 29, 2016 06:24
count total monthly hours
<?php
date_default_timezone_set('Asia/Karachi');
#################################################################
$leaves = 0; // edit this if needed
#################################################################
$hours = 8;
$workdays = array();
$type = CAL_GREGORIAN;
@sarfraznawaz2005
sarfraznawaz2005 / JsonTexter.php
Last active November 27, 2024 19:10
read and write php array to json file
<?php
/*
Class for reading and writing array data in json format
Author: Sarfraz Ahmed ([email protected])
*/
class JsonTexter
{
protected $file = null;
public function __construct($file)