Teddy Zugana

Steps to increase PermGen Heap Space in Tomcat:

1) Go to Tomcat installation directory i.e C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.14\bin in Windows and something similar in Linux.

2) Add JAVA_OPTS in your catalina.bat or Catalina.sh

In Windows:

set JAVA_OPTS=”-Xms1024m -Xmx10246m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m”

In linux:

export JAVA_OPTS=”-Xms1024m -Xmx10246m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m”

You can change the actual heap size and PermGen Space as per your requirement.

3) Restart Tomcat.

As I said earlier increasing PermGen space can prevent java.lang.OutOfMemoryError: PermGen in tomcat only for some time and it will eventually occur based on how many times you redeploy your web application, its best to find the offending class which is causing a memory leak in tomcat and fix it.

Read more: https://javarevisited.blogspot.com/2012/01/tomcat-javalangoutofmemoryerror-permgen.html#ixzz7WFe3vD98

--

--

public String getLongestCommonSubstring(String str1, String str2)
{
int m = str1.length();
int n = str2.length();

int max = 0;

int[][] dp = new int[m][n];
int endIndex=-1;
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
if(str1.charAt(i) == str2.charAt(j)){

// If first row or column
if(i==0 || j==0){
dp[i][j]=1;
}else{
// Add 1 to the diagonal value
dp[i][j] = dp[i-1][j-1]+1;
}

if(max < dp[i][j])
{
max = dp[i][j];
endIndex=i;
}
}

}
}
// We want String upto endIndex, we are using endIndex+1 in substring.
return str1.substring(endIndex-max+1,endIndex+1);
}
}

--

--

#php

<?php
$inputdata = @$_POST[‘inputdata’];
if(empty($inputdata))
{
$inputdata = @$_GET[‘inputdata’];
}
$result = array();if(is_numeric($inputdata))
{
if(!empty($inputdata))
{

$result = array();

for ($i = 0; $i < $inputdata; $i++)
{
$dataseriestemp=series($i);
if($dataseriestemp==0)
{
}
else if($dataseriestemp%2==1)
{
$result[]=$dataseriestemp;
}
}
}
}function series($num)
{
if($num == 0)
{
return 0;
}
else if($num == 1)
{
return 1;
}
else
{
return (series($num-1) + series($num-2));
}
}
rsort($result);
header(‘Content-Type: application/json’);
echo json_encode($result);
?>

--

--

#php

function getLongestMatchingSubstring($str1, $str2)
{
$len_1 = strlen($str1);
$longest = ‘’;
for($i = 0; $i < $len_1; $i++)
{
for($j = $len_1 — $i; $j > 0; $j — )
{
$sub = substr($str1, $i, $j);
if (strpos($str2, $sub) !== false && strlen($sub) > strlen($longest))
{
$longest = $sub;
break;
}
}
}
return $longest;
}

--

--

ON .htaccess Add =


Options -Indexes
<Files ~
“\.(env|json|config.js|md|gitignore|gitattributes|lock)$”>
Order allow,deny
Deny from all
</Files>
<Files ~ “(artisan)$”>
Order allow,deny
Deny from all
</Files>
<Files *.php>
Order Deny,Allow
Deny from all
</Files>
<Files index.php>
Order Allow,Deny
Allow from all
</Files>

hide .env passwords in Laravel Debug output on config/app.php file add inside return

return ['debug_blacklist' => [
'_ENV' => [
'APP_KEY',
'DB_PASSWORD',
'REDIS_PASSWORD',
'MAIL_PASSWORD',
'PUSHER_APP_KEY',
'PUSHER_APP_SECRET',
],
'_SERVER' => [
'APP_KEY',
'DB_PASSWORD',
'REDIS_PASSWORD',
'MAIL_PASSWORD',
'PUSHER_APP_KEY',
'PUSHER_APP_SECRET',
],
'_POST' => [
'password',
],
],
`];`

--

--

Teddy Zugana

Teddy Zugana

aku, selagi hidup telah menaklukan semesta