Skip to content

Instantly share code, notes, and snippets.

View naimurhasan's full-sized avatar
🏠
Working from home

Naimur Hasan naimurhasan

🏠
Working from home
View GitHub Profile
@olar94
olar94 / lol.php
Created September 4, 2018 14:11
Add product to cart and setting up custom price | woocommerce
global $woocommerce;
$woocommerce->cart->empty_cart(); //чистим
$custom_price = $price; //$price - переменная с ценой
$product_id = 11963; //id любого товара
$quantity = 1; //кол-во
$cart_item_data = array('custom_price' => $custom_price);
$woocommerce->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data );
$woocommerce->cart->calculate_totals();
$woocommerce->cart->set_session();
$woocommerce->cart->maybe_set_cart_cookies();
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@lopspower
lopspower / README.md
Last active May 3, 2024 13:26
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@atupal
atupal / select_input.py
Created June 26, 2013 06:36
Keyboard input with timeout in Python
import sys, select
print "You have ten seconds to answer!"
i, o, e = select.select( [sys.stdin], [], [], 10 )
if (i):
print "You said", sys.stdin.readline().strip()
else:
print "You said nothing!"