Skip to content

Instantly share code, notes, and snippets.

View rafsuntaskin's full-sized avatar
🎯
Focusing

Rafsun Chowdhury rafsuntaskin

🎯
Focusing
View GitHub Profile
@rafsuntaskin
rafsuntaskin / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rafsuntaskin
rafsuntaskin / javascript_resources.md
Last active August 29, 2015 14:13 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@rafsuntaskin
rafsuntaskin / last_comment_on_post.php
Created June 18, 2015 05:34
Get last comment for a wordpress post
$PostID = 215;
global $wpdb;
$p = $wpdb->prefix;
var_dump($wpdb->get_results($wpdb->prepare("SELECT comment_date FROM {$wpdb->prefix}comments WHERE comment_post_ID = %d ORDER BY comment_date DESC LIMIT 1",$PostID)));
@rafsuntaskin
rafsuntaskin / domain-migration.sql
Last active August 29, 2015 14:27
Replace Url in WP database for domain migration
SET @oldurl = 'http://oldsiteurl.com';
SET @newurl = 'http://newsiteurl.com.br';
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, @oldurl,@newurl);
UPDATE wp_posts SET post_content = replace(post_content, @oldurl, @newurl);
UPDATE wp_postmeta SET meta_value = replace(meta_value,@oldurl, @newurl);
@rafsuntaskin
rafsuntaskin / wp-query-ref.php
Created February 19, 2016 22:13 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@rafsuntaskin
rafsuntaskin / http-redirect-target.php
Created December 24, 2017 09:06
Get HTTP redirect destination for a URL in PHP
<?php
// FOLLOW A SINGLE REDIRECT:
// This makes a single request and reads the "Location" header to determine the
// destination. It doesn't check if that location is valid or not.
function get_redirect_target($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
@rafsuntaskin
rafsuntaskin / mPDF.php
Last active February 9, 2018 03:53
mpdf Stich PDFS or Merge multiple pdfs
<?php
function custom_yith_merge_PDF_Slips(Array $filenames, $outFile) {
$mpdf = new mPDF();
if ($filenames) {
$filesTotal = sizeof($filenames);
$fileNumber = 1;
$mpdf->SetImportUse();
if (!file_exists($outFile)) {
$handle = fopen($outFile, 'w');
@rafsuntaskin
rafsuntaskin / pr.md
Created February 22, 2018 08:22 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

<?php
$url = 'url';
$proxyauth = 'user:pass';
$proxy = 'proxy.server.es';
$proxyPort = '8080';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//proxy suport
@rafsuntaskin
rafsuntaskin / plugin.php
Created October 22, 2018 10:23
Add WP plugin action link
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'plugin_action_links' );
function plugin_action_links( $links ) {
$links[] = '<a href="' . admin_url( 'admin.php?page=my-plugin-settings' ) . '">' . __( 'Settings', 'text-domain' ) . '</a>';
return $links;
}