Skip to content

Instantly share code, notes, and snippets.

View musamamasood's full-sized avatar
🎯
Focusing

Muhammad Usama Masood musamamasood

🎯
Focusing
View GitHub Profile
@musamamasood
musamamasood / CreateTrigger.php
Created December 11, 2019 16:06 — forked from me-shaon/CreateTrigger.php
Sample Laravel migration to create MySQL Trigger
<?php
use Illuminate\Database\Migrations\Migration;
class CreateTrigger extends Migration
{
public function up()
{
DB::unprepared('
CREATE TRIGGER tr_after_main_insert AFTER INSERT ON `main` FOR EACH ROW
@musamamasood
musamamasood / functions.php
Created January 9, 2019 16:33 — forked from douglasanro/functions.php
Create WordPress settings page For custom options
<?php
// Let’s instantiate this class in our functions.php file:
if( is_admin() ) {
require 'simple_settings_page.php';
new simple_settings_page();
}
@musamamasood
musamamasood / CopyAsanaTasks.php
Created November 14, 2018 13:30 — forked from AWeg/CopyAsanaTasks.php
main changes: - Asana has own SSL cert -> had to add to lines of code - copies subtasks and up to 11 subtasks of subtasks - copies tags -> only tagnames not followers/descriptions
function asanaRequest($methodPath, $httpMethod = 'GET', $body = null)
{
$apiKey = 'ASANA_API_KEY_HERE'; /// Get it from http://app.asana.com/-/account_api
$url = "https://app.asana.com/api/1.0/$methodPath";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($ch, CURLOPT_USERPWD, $apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@musamamasood
musamamasood / laravel-lumen-5-homestead-win.md
Created July 12, 2017 09:52 — forked from prograhammer/laravel-lumen-5-homestead-win.md
Laravel/Lumen 5.1 Homestead for Windows (includes fixes for shared-folder related slowness, npm install problems, caching, etc)

Laravel / Lumen Homestead for Windows w/fixes

###Initial installation and configuration Install Git for Windows which includes Git Bash.

Install VirtualBox and Vagrant.

Note: These fixes were not originally done for VirtualBox 5.0 and Vagrant 1.7.4. They are for the previous versions instead: VirtualBox 4.3.30 and Vagrant 1.7.3. Some of these fixes may not be needed now. For example, I recently upgraded to VirtualBox 5.0 and Vagrant 1.7.4 and I did not have to alter the Vagrant ruby (.rb) files as shown in part of this Gist below. I'll soon try from a fresh install (not upgrade) and update this Gist accordingly.

In Git Bash (always run as administrator), type cd ~ to

@musamamasood
musamamasood / _ide-helper.php
Created June 19, 2017 17:51 — forked from torounit/_ide-helper.php
PHPStorm等でWordPressのグローバル変数の入力補完を有効にする。プロジェクトのどこかに置いておくと補完されるようになる。
<?php
trigger_error("This file should not be included, only analyzed by your IDE", E_USER_ERROR);
$wp_the_query = new WP_Query();
/** @var WP_Query $wp_query */
$wp_query = $wp_the_query;
$wp_rewrite = new WP_Rewrite();
$wp = new WP();
@musamamasood
musamamasood / gist:68d77c7786f7aef624e5778edcdfe7f8
Created April 25, 2017 20:11 — forked from billerickson/gist:2047229
Improve performance of WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
@musamamasood
musamamasood / gitBash_windows.md
Created March 23, 2017 20:44 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows is bundled with "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on). If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corrisponding directories. Sometimes the windows binary have funny prefixes, so you should rename the exe file to the

@musamamasood
musamamasood / r-debug.php
Created January 19, 2017 21:26 — forked from Rarst/r-debug.php
R Debug (set of dump helpers for debug)
<?php
/*
Plugin Name: R Debug
Description: Set of dump helpers for debug.
Author: Andrey "Rarst" Savchenko
Author URI: http://www.rarst.net/
License: MIT
*/
/**
@musamamasood
musamamasood / wordpress_export-post-data.php
Created January 4, 2017 18:02 — forked from robinnorth/wordpress_export-post-data.php
WordPress: Simple, configurable script to export post data to a CSV file
<?php
/**
* Export WordPress post data to CSV
* Based on <http://stackoverflow.com/a/3474698> and <http://ran.ge/2009/10/27/howto-create-stream-csv-php/>
*/
/**
*********************************************************************
* Configuration
*********************************************************************
@musamamasood
musamamasood / gist:f71fe99071447f36f70468081dd742cb
Created September 16, 2016 18:39 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>