Skip to content

Instantly share code, notes, and snippets.

View hsleonis's full-sized avatar
🏝️
Travellers unite.

Hasan Shahriar hsleonis

🏝️
Travellers unite.
View GitHub Profile
@hsleonis
hsleonis / all_unique.md
Created May 25, 2020 20:54
Returns True if all the values in a list are unique, False otherwise.
def all_unique(lst):
  return len(lst) == len(set(lst))
x = [1, 2, 3, 4, 5, 6]
y = [1, 2, 2, 3, 4, 5]
all_unique(x) # True
all_unique(y) # False
@hsleonis
hsleonis / all_equal.md
Created May 25, 2020 20:48
Checks if all elements in a list are equal.
def all_equal(lst):
  return lst[1:] == lst[:-1]
all_equal([1, 2, 3, 4, 5, 6]) # False
all_equal([1, 1, 1, 1]) # True
@hsleonis
hsleonis / iterator.py
Last active May 15, 2020 23:04
Pandas
# Create a list of strings: flash
flash = ['jay garrick', 'barry allen', 'wally west', 'bart allen']
# Print each list item in flash using a for loop
for item in flash:
print(item)
# Create an iterator for flash: superhero
superhero = iter(flash)
# Print each item from the iterator
print(next(superhero))
print(next(superhero))
@hsleonis
hsleonis / shopify-footer-bgimage.liquid
Created April 21, 2020 17:06
Add background image to footer section in shopify
@hsleonis
hsleonis / google-maps-shortcode.php
Created May 21, 2019 22:50
Google Maps Shortcode with Multiple & Custom Markers and Info Window
<?php
function store_map_enqueue_scripts(){
global $cmb_booking, $cmb_review, $cmb_store, $cmb_user, $contentLang;
//load full version or minified version of javascript
//$prefix = WP_DEBUG ? '' : '.min';
$prefix = NULL;
// Google Fonts
//wp_enqueue_style( 'natosans', '//fonts.googleapis.com/css?family=Noto+Sans:400,700');
@hsleonis
hsleonis / woocommerce-optimize-scripts.php
Created April 22, 2018 06:13 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@hsleonis
hsleonis / digits-conversion.php
Last active April 19, 2018 18:19
English digits to Bengali in PHP
<?php
function changeDigitsEtoB( $digits ) {
$bangla = numfmt_format(numfmt_create( 'bn_BD', NumberFormatter::TYPE_DEFAULT ),$digits);
return $bangla;
}
@hsleonis
hsleonis / django.bat
Created January 4, 2018 04:52
Django initialize with app & admin
@echo off
set /p UserInputPath= Enter directory name :
:: mkdir %UserInputPath%
:: mkvirtualenv biman
:: workon biman
:: pip install django
:: pip install django-admin
django-admin startproject %UserInputPath%
@hsleonis
hsleonis / admin-title.py
Created January 2, 2018 11:37
Change admin URL
admin.site.site_header = 'The Suncoin Admin'
admin.site.index_title = 'Admin Panel'
admin.site.site_title = 'The Suncoin'
@hsleonis
hsleonis / zip-maker.py
Created January 2, 2018 11:36
Create zip file
def home(request):
inMemoryOutputFile = BytesIO()
# zipFile = ZipFile(inMemoryOutputFile, 'w')
# zipFile.writestr('OEBPS/content.xhtml', 'hello world')
# zipFile.close()
zipfile = ZipFile(inMemoryOutputFile, "w")
zipfile.writestr("AB/stuff.txt","1sdfghj")
zipfile.writestr("AB/two.txt","2sdfghj")