Skip to content

Instantly share code, notes, and snippets.

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

Ravi Kumar Gupta kravigupta

🏠
Working from home
View GitHub Profile
@kravigupta
kravigupta / package.json
Created June 30, 2021 13:14
Package.json after npm init -y
{
"name": "r-typescript-setup-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
@kravigupta
kravigupta / base64_decode_to_hex.py
Created February 21, 2019 14:56
base64_decode_to_hex.py
def base64_decode_to_hex(s):
"""Helper function to convert the base64 encoded string to hex format.
:param s: string to convert to hex
:returns: decoded string
"""
import base64
decoded = base64.b64decode(s)
return decoded
@kravigupta
kravigupta / get-mssql-size.sql
Created March 18, 2018 18:39
Database query for MSSql to get size of database in MBs
SELECT
database_name = DB_NAME(database_id)
, log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2))
, row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2))
, total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2))
FROM sys.master_files WITH(NOWAIT)
WHERE database_id = DB_ID() -- for current db
GROUP BY database_id
@kravigupta
kravigupta / portal-ext.properties
Created March 18, 2018 18:38
portal-ext.properties file configuration for JCR and Images upgrade.
jcr.initialize.on.startup=true
#
# Set the name of a class that implements
# com.liferay.portlet.documentlibrary.store.Store. The
# document library server will use this to persist documents.
#
dl.store.impl=com.liferay.portlet.documentlibrary.store.JCRStore
##
## Images
@kravigupta
kravigupta / updated-repository.xml
Created March 18, 2018 18:37
updated-repository.xml
<?xml version="1.0"?>
<Repository>
<!--
Database File System (Cluster Configuration)
This is sample configuration for mysql persistence that can be used for
clustering Jackrabbit. For other databases, change the connection,
credentials, and schema settings.
@kravigupta
kravigupta / default-repository.xml
Created March 18, 2018 18:35
Default Repository.xml file
<?xml version="1.0"?>
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/repository" />
</FileSystem>
<!--
Database File System (Cluster Configuration)
This is sample configuration for mysql persistence that can be used for
@kravigupta
kravigupta / GetPrefs.java
Created March 18, 2018 18:34
Get Preferences of another portlet
DynamicQuery query = DynamicQueryFactoryUtil.forClass(
PortletPreferences.class).add(
PropertyFactoryUtil.forName("portletId").like("%myportletA%"));
List<Object> preferences = PortletPreferencesLocalServiceUtil.dynamicQuery(query);
for (Object preferencesPart : preferences) {
System.out.println("Prefs value is varA "+((PortletPreferences) preferencesPart).getPreferences());
javax.portlet.PortletPreferences prefs = PortletPreferencesFactoryUtil.fromDefaultXML(((PortletPreferences) preferencesPart).getPreferences());
System.out.println(prefs.getValue("varA", "0"));
@kravigupta
kravigupta / catalina.properties
Created March 18, 2018 18:32
catalina.properties file
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@kravigupta
kravigupta / ROOT.xml
Created March 18, 2018 18:31
ROOT.xml
<Context path="" crossContext="true">
<!-- JAAS -->
<!--<Realm className="org.apache.catalina.realm.JAASRealm"
appName="PortalRealm"
userClassNames="com.liferay.portal.kernel.security.jaas.PortalPrincipal" roleClassNames="com.liferay.portal.kernel.security.jaas.PortalRole" />-->
<!-- Uncomment the following to disable persistent sessions across reboots. -->
@kravigupta
kravigupta / wrapper.conf
Created March 18, 2018 18:28
Wrapper.conf file
wrapper.java.additional.8="-Xmx2048M"
wrapper.java.additional.9="-Xss256K"
wrapper.java.additional.10="-XX:MaxPermSize=256m"
wrapper.java.additional.11="-Dfile.encoding=UTF-8"