Skip to content

Instantly share code, notes, and snippets.

View hmphu's full-sized avatar
🎯
Focusing

Hoang Manh Phu hmphu

🎯
Focusing
View GitHub Profile
@hmphu
hmphu / 01_utils.py
Created September 29, 2020 03:56 — forked from mbrochh/01_utils.py
Using pagination with Django, graphene and Apollo
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
# First we create a little helper function, becase we will potentially have many PaginatedTypes
# and we will potentially want to turn many querysets into paginated results:
def get_paginator(qs, page_size, page, paginated_type, **kwargs):
p = Paginator(qs, page_size)
try:
page_obj = p.page(page)
except PageNotAnInteger:
@hmphu
hmphu / Providers.js
Created September 9, 2020 03:06 — forked from ishan123456789/Providers.js
Fix for strapi to allow multiple providers
// /extensions/users-permissions
"use strict";
/**
* Module dependencies.
*/
// Public node modules.
const _ = require("lodash");
const request = require("request");
@hmphu
hmphu / install-configure-letsencrypt.sh
Last active July 15, 2020 11:45 — forked from craigvantonder/install-configure-letsencrypt.md
Install and configure LetsEncrypt on Ubuntu Server 14.04 & 16.04 (Apache)
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04
# Download the Let’s Encrypt Client
cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto
# Set Up the SSL Certificate
# file .ddev/docker-compose.redis.yaml
# ddev redis recipe file
#
version: '3'
services:
redis: # This is the service name used when running ddev commands accepting the --service flag
container_name: ddev-${DDEV_SITENAME}-redis # This is the name of the container. It is recommended to follow the same name convention used in the main docker-compose.yml file.
image: redis:4
@hmphu
hmphu / .htaccess
Created September 3, 2019 17:09 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@hmphu
hmphu / README.md
Created August 27, 2019 07:15 — forked from simov/README.md
Run `node` scripts using `nvm` and `crontab` without hardcoding the node version

Run node scripts using nvm and crontab without hardcoding the node version

cronjob.env.sh

#!/bin/bash

# NVM needs the ability to modify your current shell session's env vars,
# which is why it's a sourced function
@hmphu
hmphu / fix-billing-address-issue.diff
Created July 24, 2019 09:51
Fix Magento 2.3.2 Js issue related to billing address: Uncaught ReferenceError: Unable to process binding "if: function(){return (addressOptions.length > 1) }" Message: addressOptions is not defined
diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php
index 557f1433..2313fda5 100644
--- a/Block/Checkout/LayoutProcessor.php
+++ b/Block/Checkout/LayoutProcessor.php
@@ -157,15 +157,15 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcessor
$elements = $this->getAddressAttributes();
$elements = $this->convertElementsToSelect($elements, $attributesToConvert);
// The following code is a workaround for custom address attributes
- if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
- ['payment']['children'])) {
@hmphu
hmphu / basicAuthVCL4.vcl
Created July 19, 2019 03:54 — forked from section-io-gists/basicAuthVCL4.vcl
basicAuthVCL4.vcl
sub vcl_recv {
if (! req.http.Authorization ~ "Basic dXNlcm5hbWU6cGFzc3dvcmQ=") {
# This is checking for base64 encoded username:password combination
return(synth(401, "Authentication required"));
}
unset req.http.Authorization;
}
@hmphu
hmphu / PAYPA_BUTTON
Created May 2, 2019 09:52
PAYPAL BUTTON VALUES EXPLANATION
// ------------------------------------------------------------
// PAYPAL BUTTON VALUES EXPLANATION
// ------------------------------------------------------------
- name="cmd" value="_xclick-subscriptions" - The button that the person clicked was a Subscribe button.
- name="business" - Your PayPal ID or an email address associated with your PayPal account. Email addresses must be confirmed.
- name="lc" value="US" - The language of the login or sign-up page that subscribers see when they click the Subscribe button. If unspecified, the language is determined by a PayPal cookie in the subscriber's browser. If there is no PayPal cookie, the default language is U.S. English.
- name="item_name" - Description of item. If omitted, payers enter their own name at the time of payment.
- name="item_number" - Pass-through variable for you to track product or service purchased or the contribution made. The value you specify passed back to you upon payment completion.
- name="no_note" - Do not prompt payers to include a
@hmphu
hmphu / index.html
Created March 27, 2019 11:54 — forked from NFoxley/index.html
Maintenance
<style>
body {
height: 100vh;
font-family: "Source Sans Pro", Roboto, Arial, sans-serif;
}
.wrapper {
display: flex;
flex-direction: column;
justify-content: center;