Skip to content

Instantly share code, notes, and snippets.

View vahidhedayati's full-sized avatar

Vahid Hedayati vahidhedayati

View GitHub Profile
#!/bin/bash
echo "-----------------------------------------------------------------------"
echo "MEMORY"
echo "-----------------------------------------------------------------------"
free -h
echo
echo "-----------------------------------------------------------------------"
echo "LOAD"
echo "-----------------------------------------------------------------------"
w|grep load |awk -F"load" '{print "Load"$NF}'
public class EmailService {
public void sendEmail(
if (siteConfig != null) {
mailSender(siteConfig).send(mimeMessage);
} else {
this.javaMailSender.send(mimeMessage);
}
}
/*
@vahidhedayati
vahidhedayati / jasper-produce-pdf.java
Last active November 1, 2022 19:54
jaspe produce pdf
public void jasperPDF(HttpServletResponse response) throws JRException, IOException {
//Compiled report
InputStream jasperStream = (InputStream) this.getClass().getResourceAsStream("/file.jasper");
//Adding attribute names
Map params = new HashMap<>();
params.put("id","123");
params.put("name","dd");
@vahidhedayati
vahidhedayati / namedParameterJdbcTemplate-Dynamic-map.java
Created September 6, 2022 06:58
Return a dynamic map regardless of query using namedParameterJdbcTemplate
List<Map<String, Object>> result = namedParameterJdbcTemplate.query(query, whereParams, rs -> {
List<Map<String, Object>> rows = new ArrayList<>();
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
while (rs.next()) {
Map<String, Object> columns = new LinkedHashMap<>();
for (int i = 1; i <= columnCount; i++) {
columns.put(metaData.getColumnLabel(i), rs.getObject(i));
}
rows.add(columns);
@vahidhedayati
vahidhedayati / unicode.md
Last active July 24, 2022 11:30
How to capture Unicode Special Characters for DB storage when DB can't store special characters.

There are a few different approaches to fix work around such an issue, I will walk through what I think is the best approach

  1. The simplest is to use convert special characters to it's integer value and get the hex string of the integer value to produce a the underlying unicode.

You will need to convert at point of call to store

String testString ="well hello there ™ and then © at there ™ ©  ™ © ™ © ";
import { Options, Vue } from 'vue-class-component'
import useProducts from '../composables/products'
@Options({
props: {
msg: String
}
})
export default class HelloWorld extends Vue {
msg!: string
// Class properties will be component data
@vahidhedayati
vahidhedayati / vuex.md
Last active November 27, 2019 16:39
vuex mutations/actions
@vahidhedayati
vahidhedayati / publish-vue-to-npm.md
Last active November 20, 2019 16:17
How to publish a vue js plugin to npm

This is a guide after trying to figure out how to publish to npm

After creating a directory

run npm init inside folder you will need a few base files

Answer questions and this will produce a package.json

Follow some of the base files in this folder and update definitions to match your plugin

I have added 2 new fields remoteKey remoteValue to the VoerroTagsInput.vue which is referred to by other local vue These are the definitions of what comes back from the db - so a db could have city object stored and it could come back as cityId and cityName as the two fields we are searching for from a given dynamic data set -

In this gist I have included 2 other files:

  1. a wrapper class for VoerroTagsInput.vue which is referred to by other local vue
  2. The actual example vue calling and rewriting db data to match above sample and VoerroTagsInput.vue appears to locally work fine
@vahidhedayati
vahidhedayati / incept-minikube.sh
Created November 1, 2018 09:37 — forked from osowski/incept-minikube.sh
Install Minikube, Kubectl, and Virtualbox on Ubuntu
#Installing VirtualBox
echo "Installing VirtualBox........................"
sudo apt-get install virtualbox
#Installing kubectl https://kubernetes.io/docs/getting-started-guides/kubectl/
echo "Installing kubectl..........................."
wget https://storage.googleapis.com/kubernetes-release/release/v1.4.4/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl