Skip to content

Instantly share code, notes, and snippets.

View qutek's full-sized avatar
💻
Working from home

Lafif Astahdziq qutek

💻
Working from home
View GitHub Profile
@qutek
qutek / fix-homebrew-npm.md
Created November 5, 2015 06:11 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
@qutek
qutek / wp-config.php
Created March 29, 2016 08:15
[Wordpress] Prevent error and slow loading (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) normally on local development
<?php
// add this line on wp-config.php
define( 'WP_HTTP_BLOCK_EXTERNAL', true );
@qutek
qutek / horizontal-infinite-carousel.html
Created April 16, 2017 05:24 — forked from dongyuwei/horizontal-infinite-carousel.html
infinite loop carousel(vertical or horizontal)
@qutek
qutek / generate_ssl.md
Last active November 22, 2023 00:49
[Server][MacOs] Generate local SSL with SAN (Subject Alternative Name), works with Chrome 5.8+

Generate local SSL with SAN

Since version 58, Chrome requires SSL certificates to use SAN (Subject Alternative Name) instead of the popular Common Name (CN), thus CN support has been removed.

To create SSL with SAN, use steps as follows

  • Go to your target ssl directory (mine was /usr/local/etc/httpd/ssl)
  • Create .conf file
  • Generate SSL
  • Point the cert on your apache conf
@qutek
qutek / question-1.php
Last active October 9, 2017 11:24
WP Quiz
<?php
/**
* Question #1
* Scenario:
* 1. We have a list of companies in the Company custom post type.
* 2. Each Company has a ranking which is stored in post meta with a key called `ranking. The ranking is a decimal value between 0 and 100. A sample `ranking` is 94.9.
* 3. Each Company can also be marked as sponsored. If a Company is sponsored, a post meta with a key called `sponsored` is updated to 1. Otherwise, the `sponsored` meta value is `0` for each Company.
*
* Problem:
* Given the above scenario, provide the correct array of $args to pass into a new WP_Query instance so that we can return 100 companies with the "sponsored" companies first, and then after that sorted, from highest to lowest based off the `ranking` value.
@qutek
qutek / o2a.php
Created December 29, 2017 03:21
[PHP Convert multidimensional object to array] #php #array
<?php
/**
* Convert object to array
* @param [type] $obj [description]
* @return [type] [description]
*/
function obj_to_array($obj) {
if(!is_array($obj) && !is_object($obj))
return $obj;
@qutek
qutek / calculateStripeFee.js
Created February 3, 2018 06:20
[Calculate Stripe Fee] Calculate stripe fee to ask customer to cover stripe fee #javascript #stripe
/**
* Calculate stripe fee from amount
* so you can charge stripe fee to customers
* lafif <[email protected]>
*/
var fees = {
USD: { Percent: 2.9, Fixed: 0.30 },
GBP: { Percent: 2.4, Fixed: 0.20 },
EUR: { Percent: 2.4, Fixed: 0.24 },
CAD: { Percent: 2.9, Fixed: 0.30 },
@qutek
qutek / debug-email.php
Last active March 14, 2018 07:31
[Debug Email] Simple script to change all email recipients for debugging / development purpose #wordpress #email #development-tools
<?php
/**
* Plugin Name: Debug Email
* Description: Simple script to change all email recipients for debugging / development purpose
* Version: 0.1
* Author: Lafif Astahdziq
* Author URI: https://lafif.me
*/
add_action( 'init', 'test_send_email' );
@qutek
qutek / instruction.md
Last active November 7, 2023 12:45
[Install ZeroMQ MAC] Install PHP ZeroMQ MAC #mac #php

Install with brew

  • brew install zmq

Make php-zmq

  • git clone git://github.com/mkoppanen/php-zmq.git
  • cd php-zmq
  • phpize && ./configure
  • make && make install

Add extension to php.ini:

@qutek
qutek / force-login.php
Last active March 28, 2020 21:16
[ Force Login ] Force login WordPress user without password, use it as plugin or place the code under mu-plugins / wp-config.php ( after `require_once(ABSPATH . 'wp-settings.php');` )
<?php
/**
* Auto login user without password, access with <code>http://domain.com/?force_login=username</code>
* [email protected]
*/
if ( ! defined( 'WP_CLI' ) ) {
function force_login() {
if( !isset($_GET[ 'force_login' ]) || empty( $_GET[ 'force_login' ] ) )
return;