Skip to content

Instantly share code, notes, and snippets.

View bmvakili's full-sized avatar

Bijan Vakili bmvakili

View GitHub Profile
@bmvakili
bmvakili / find-lib-in-bin.sh
Created May 23, 2013 23:46
Show all libraries used by executables on linux To find the answer for all executables in the "/bin" directory:
#http://stackoverflow.com/questions/50159/show-all-libraries-used-by-executables-on-linux
find /bin -type f -perm /a+x -exec ldd {} \; \
| grep so \
| sed -e '/^[^\t]/ d' \
| sed -e 's/\t//' \
| sed -e 's/.*=..//' \
| sed -e 's/ (0.*)//' \
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.airhacks</groupId>
<artifactId>javaee7-essentials-pom</artifactId>
<version>7.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
@bmvakili
bmvakili / Fancy Statistics 1
Created December 27, 2013 04:48
Liferay Marketplace - Portal Statistics - Template
<#assign liferay_ui = taglibLiferayHash["/WEB-INF/tld/liferay-ui.tld"] />
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Value
</th>
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
@bmvakili
bmvakili / dbupdate_after_service_builder
Created January 18, 2014 00:06
update iff tables already created with service builder, update id_ to id
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_name) INTO @tables
FROM information_schema.columns
WHERE table_schema = (SELECT DATABASE()) AND (LOWER(table_name) like 'x%' OR LOWER(table_name) like 'sm%' OR LOWER(table_name) like 'invites%' OR LOWER(table_name) like 'blockvendor%' ) AND column_name = 'id_';
select REPLACE(@tables, ',', ' change id_ id int(11) ; alter table ') into @tables;
select CONCAT('alter table ', @tables) into @tables;
@bmvakili
bmvakili / bash.sh
Created March 6, 2014 22:27
Merge and keep lines from both files, don't delet
#/bin/bash
diff --old-line-format='%L' --new-line-format='%L' $1 $2 > $2
@bmvakili
bmvakili / bash.sh
Created March 6, 2014 22:28
Format the XML and write in-place
#!/bin/bash
## Not you can do XMLLINT_INDENT="(Ctrl+V, Ctrl+I)" to change indent to tab
xmllint -o $1 --format $1
@bmvakili
bmvakili / create-new-user-and
Last active August 29, 2015 13:58
Liferay Miscellanious util scripts. Assign template to a user's pages. Written in Beanshell for Liferay Script page.
import com.liferay.portal.model.*;
import com.liferay.portal.service.*;
import com.liferay.counter.service.*;
import com.liferay.portal.util.*;
import java.util.*;
/*********** MODIFY THESE VARIABLES **********/
templateName = "User Profile Site Template"; // name of a site template
/*********** DEBUG VARIABLES *****************/
@bmvakili
bmvakili / create-user-check-password-required
Created April 10, 2014 06:00
Liferay Miscellanious util scripts. Create user, check password required. Written in Beanshell for Liferay Script page.
import com.liferay.portal.model.*;
import com.liferay.portal.service.*;
import com.liferay.counter.service.*;
import com.liferay.portal.util.*;
import java.util.*;
import org.apache.commons.lang.exception.*;
/*********** DEBUG VARIABLES *****************/
dbg = "";
C = "\n";
@bmvakili
bmvakili / liferay-groovy-print-the-debug-info
Created April 29, 2014 21:42
Liferay Groovy Script Print Debug Info
import java.util.*;
import java.io.*;
Process proc = new ProcessBuilder("/bin/bash", "-c",
"ifconfig; env | sort; ps -ef | grep -i java").start();
Reader reader = new InputStreamReader(proc.getInputStream());
int ch;
String output = "";
while ((ch = reader.read()) != -1)