Skip to content

Instantly share code, notes, and snippets.

View pejantantangguh's full-sized avatar
🎯

Herman Ng pejantantangguh

🎯
View GitHub Profile
name = input("Your name please?")
age = int(input("Please enter your age?")) + 100
print("Your name is "+name+ " and in 100 years you will be "+str(age))
num = int(input("Please enter first number"))
check = int(input("Please enter second number"))
result = check/num
if(result % 4 == 0):
print ( str(result)+ "\nYour number is a number multiple of 4")
elif(result % 2 == 1):
print ( str(result)+ "\nYour result is an odd number")
else:
print ( str(result)+ "\nYour result is an even number")
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
num = int(input("Please enter number"))
x = []
for element in a:
if element < num :
x.append(element)
print (x)
num = int(input("Please put a number to divide"))
divisorList = []
listRange = list(range(1,num+1))
for number in listRange:
if num % number == 0:
divisorList.append(number)
print (divisorList)
@pejantantangguh
pejantantangguh / 05. List Overlap
Created November 15, 2017 04:51
To generate random number and put it in list, cross check the value of each list and only print number that are exist in list[a] and list[b]
import random
a = random.sample(range(50),20) #Sample won't have any duplicate value
b = random.sample(range(50),20)
#See number that are generated by a
print (a)
#See number that are generated by b
print (b)
c = []
@pejantantangguh
pejantantangguh / 06. String List.py
Created November 15, 2017 05:27
If statement if input words is palindrom or not
# Strings are list
words = str(input("Type in words that you think is palindrome : "))
palindrome = words[::-1]
print (words+" "+palindrome)
if words == palindrome:
print("Your words is palindrome")
else :
print("Unfortunately this is not palindrome")
import random
number = random.sample(range(50),20)
evenNumber = []
print (number
)
for even in number:
if even % 2 == 0:
evenNumber.append(even)
@pejantantangguh
pejantantangguh / singleproductview.php
Created July 25, 2018 20:56
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
$query_args = array( 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
@pejantantangguh
pejantantangguh / ordernotes.php
Created July 30, 2018 06:59
Adding notes on selected shipping method woo
<?php $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ) ;?>
<?php $chosen_shipping = $chosen_methods[0];?>
<?php if ($chosen_shipping == 'local_pickup:26') : ?>
<p><small>Collect your order and enjoy a 30% voucher off your next in store purchase of artwork</small></p>
<?php endif; ?>
@pejantantangguh
pejantantangguh / index.php
Last active October 10, 2018 11:10
Multiple Store Set up in Magento 2
<?php
switch ($_SERVER['HTTP_HOST']) {
case 'www.domain1xx.com.au':
case 'domain1xx.com.au':
$params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'domain1xx';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
break;