Skip to content

Instantly share code, notes, and snippets.

View hasinhayder's full-sized avatar
🚀
Back on track, yayyyy!

Hasin Hayder hasinhayder

🚀
Back on track, yayyyy!
View GitHub Profile
@hasinhayder
hasinhayder / functions.php
Created October 29, 2014 19:12
Redirect WordPress posts to the editor if someone types /edit at the end of the permalink
<?php
function init_url_rewrite_rule(){
add_rewrite_endpoint( 'edit',EP_PERMALINK | EP_PAGES | EP_ATTACHMENT );
if(get_option("EDIT_REWRITE_RULE")!=1){
flush_rewrite_rules();
update_option("EDIT_REWRITE_RULE",1);
}
}
function redirect_edit_url(){
@hasinhayder
hasinhayder / enq-js.php
Last active March 4, 2016 15:59
generate wp_enqueue_script calls for all the js files in the current directory
#!/usr/bin/env php
<?php
foreach(glob("*.js") as $js){
echo "wp_enqueue_script( 'wptheme-{$js}', get_template_directory_uri().'/js/{$js}', array('jquery'),'1.0',true);\n";
}
@hasinhayder
hasinhayder / _ide_helper.php
Created July 11, 2016 20:01 — forked from barryvdh/_ide_helper.php
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.1.31 (LTS) on 2016-03-01.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
@hasinhayder
hasinhayder / curl_progress.php
Created September 1, 2016 20:16 — forked from bdunogier/curl_progress.php
PHP/cURL download progress monitoring
<?php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( 'http://ftp.free.org/mirrors/releases.ubuntu-fr.org/11.04/ubuntu-11.04-desktop-i386-fr.iso' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );
sudo chown -R $(whoami) /usr/local
@hasinhayder
hasinhayder / Migration.js
Created March 21, 2017 09:00 — forked from stevebrun/Migration.js
A script for migrating the primary domain of a Google Apps account.
// migrate the script executer's primary domain
// domainName - the desired domain to migrate to
function migrateDomain(organizationName, domainName) {
var customerId = 'my_customer';
var customer = AdminDirectory.Customers.get(customerId);
customer.customerDomain = domainName;
customer.postalAddress.organizationName = organizationName;
customer.customerCreationTime = undefined; //
AdminDirectory.Customers.patch(customer, customerId);
@hasinhayder
hasinhayder / imgreplace.php
Created June 5, 2017 09:12
Replace images with Dummy Placeholder Image
<?php
/* Keep your images in a folder named 'img' in the same folder where this script resides*/
/* Run the command "php imagereplace.php */
/* ImageMagick PHP extension is required */
function getDirContents($dir, &$results = array()) {
$files = scandir($dir);
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
@hasinhayder
hasinhayder / resize-slash-tmp-tmpfs.sh
Created September 12, 2017 14:45
Resize /tmp size in Linux
mount -o remount,size=5G,noatime /tmp
Also the following line in /etc/fstab helps
none /tmp tmpfs defaults,size=5000000000 0 0
But make sure that /etc/default/rcS
RAMTMP=no
Also in /etc/defaults/tmpfs
@hasinhayder
hasinhayder / command.sh
Last active September 13, 2017 12:55
Fix broken partiton on a pendrive in Mac OSX. After this command, you can find partition button ok in disk utility and Encryption will be available again
diskutil erasedisk hfs+ External GPT /dev/disk2
@hasinhayder
hasinhayder / ssh-config
Created August 24, 2017 13:12
Keep ssh connections alive in terminal
ServerAliveInterval 10
TCPKeepAlive yes