Skip to content

Instantly share code, notes, and snippets.

View ri5h's full-sized avatar
πŸ‘¨β€πŸ’»
Working from home

Rishiraj Purohit ri5h

πŸ‘¨β€πŸ’»
Working from home
View GitHub Profile
@ri5h
ri5h / header.php
Last active June 20, 2016 20:02
Woocommerce, get cart total , get total number of items in care , get woocommerce shop page , get checkout page and other things.
global $woocommerce;
//Get url of cart page
$cart_url = WC_Cart::get_cart_url(); //one way to do it
$checkout_url = WC_Cart::get_checkout_url();
//Get total value of cart
$cart_total = $woocommerce->cart->get_cart_total(); //other way to do it
//Get number of cart items
public void checkPerms(){
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE)) {
// Show an explanation to the user *asynchronously* -- don't block
@ri5h
ri5h / MainActivity.java
Created June 19, 2017 08:18
Get files from android device
package in.rishirajpurohit.android.fileaccess;
import android.Manifest;
import android.content.ContentResolver;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Color;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
@ri5h
ri5h / home.html
Created September 1, 2018 08:17
Basic html tags intro
<html>
<head>
<title>GIT Home</title>
</head>
<body >
<h1>Welcome to GIT</h1>
<br/>
<hr/>
<br/>
@ri5h
ri5h / SamplePage1.html
Created September 1, 2018 09:16
Sample page header section
<!-- http://therunapp.co/wp-content/uploads/2018/06/simple-website-download-sample-html-page-template-login-free.jpg -->
<!DOCTYPE html>
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<!-- Header -->
<div style="background-color:#12ac90;height: 200px;">
@ri5h
ri5h / composerInfo.py
Created September 28, 2020 22:32
Read composer.json and composer.lock
# Which directory have composer.json and composer.lock
parser = argparse.ArgumentParser()
parser.add_argument('--path', help='Relative directory that contains the composer files')
cdir = parser.parse_args().path
# Reads composer.json for constraints
reqPack = {}
with open(cdir +'/composer.json') as json_file:
data = json.loads(json.dumps(json.load(json_file)))
for package in data['require']:
@ri5h
ri5h / packagistInfo.py
Created September 28, 2020 22:36
Read package info from packagist
# Read the latest version available from packagist
finalRes = []
for package in reqPack:
finalPackageResult = {
'name': package
}
# Try to get info from packagist (works with or w/o repo)
url = 'https://repo.packagist.org/packages/' + package + '.json'
jsonMetaRes = requests.get(url)
@ri5h
ri5h / versionInfo.py
Created September 28, 2020 22:41
Finding versions with semantic-version library
for package in reqPack:
finalPackageResult = {
'name': package
}
# Find current installed version
try:
cur_ver = semver.Version.coerce(inPack[package])
except ValueError:
if re.search("^v[0-9].*$", inPack[package]):
@ri5h
ri5h / mksites.py
Created November 20, 2020 18:27
Create a new localhost site with domain in macos, please change the user value and path as required
#!/usr/bin/env python3
import argparse
from pathlib import Path
# Define available arguments
parser = argparse.ArgumentParser(
description="Create a new .loc site for local development. It will create a new folder inside ~/Sites, add a virtualhost and an entry in /etc/hosts")
parser.add_argument('siteName', metavar='Site Name',
help='Name of the site to create')
parser.add_argument('--debug', help='display debug information')
<head>
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@flickr" />
<meta name="twitter:title" content="Small Island Developing States Photo Submission" />
<meta name="twitter:description" content="View the album on Flickr." />
<meta name="twitter:image" content="https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg" />
<meta property="og:url" content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="When Great Minds Don't Think Alike" />