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 / 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 / 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 / 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 / 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 / whatissoslow.php
Last active August 29, 2015 14:27 — forked from Viper007Bond/whatissoslow.php
WordPress: Times how long it takes each filter and action to run and displays results at the end of the page. Quick and dirty.
<?php
/**
* This little class records how long it takes each WordPress action or filter
* to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
*
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
*
@qutek
qutek / functions.php
Created June 4, 2015 04:58
[Wordpress][Snipets] Get featured image url or first image on content
<?php
/**
* Get the Featured image URL of a post
* @global object $post
* @param string $size
* @return string
*/
function funkmo_get_post_thumbnail_url($post_id='') {
$image_url = '';
@qutek
qutek / functions.php
Created May 22, 2015 02:34
[Wordpress] Custom display setting section do_setting_section()
<?php
function custom_do_settings_sections($page) {
global $wp_settings_sections, $wp_settings_fields;
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
return;
foreach( (array) $wp_settings_sections[$page] as $section ) {
echo "<h3>{$section['title']}</h3>\n";
call_user_func($section['callback'], $section);
@qutek
qutek / file.php
Created May 20, 2015 04:35
[php] Replace special character using preg replace
<?php
//Remove from a single line string
$output = "Likening ‘not-critical’ with";
$output = preg_replace('/[^(\x20-\x7F)]*/','', $output);
echo $output;
//Remove from a multi-line string
$output = "Likening ‘not-critical’ with \n Likening ‘not-critical’ with \r Likening ‘not-critical’ with. ' ! -.";
$output = preg_replace('/[^(\x20-\x7F)\x0A\x0D]*/','', $output);
echo $output;
@qutek
qutek / file.php
Created May 15, 2015 04:30
[php][array] get random most priority value
<?php
/**
* getMostPriority()
* Utility function for getting random values with weighting.
* Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50)
* An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
* The return value is the array key, A, B, or C in this case. Note that the values assigned
* do not have to be percentages. The values are simply relative to each other. If one value
* weight was 2, and the other weight of 1, the value with the weight of 2 has about a 66%
* chance of being selected. Also note that weights should be integers.
@qutek
qutek / repeatable-fields-metabox.php
Last active August 29, 2015 14:21 — forked from helen/repeatable-fields-metabox.php
Repeatable field for metabox
<?php
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {