Skip to content

Instantly share code, notes, and snippets.

@qingl97
qingl97 / gist:52881fac3dc8e6e287a9
Last active August 29, 2015 14:13
Build program using both MPI and openMP

First install openMPI on your target system.

As openMPI suggests strongly to use its wrapper compilers(GCC version 4.2, can be checked by ompi_info | grep 'C compiler' command), the wrapper compiler doesn't support openMP. OpenMP_3.1 version is supported since gcc_4.7. The wrapper compiler is just out of date to support openMP. The solution is to change the default wrapper compiler to another compiler that supports openMP.

On Linux, use export OMPI_CC=gcc to change the wrapper compiler to the gcc compiler on your local linux system.

On Mac OSX(10.9.5), the default compiler is Apple LLVM version 6.0(x86_64-apple-darwin13.4.0), which doesn't support openMP by default. One solution is to use the Intel C/C++ compiler as the openMPI wrapper compiler. Use export OMPI_CC=icc to change it.

Ref:

@qingl97
qingl97 / gist:d40150f7fa320051a785
Last active July 6, 2016 11:47
Alfresco Share doesn't show Admin Console page when running from Alfresco SDK 2.0
@qingl97
qingl97 / gist:605b26bf7ee7716560bb
Created March 26, 2015 09:12
Alfresco content model
https://wiki.alfresco.com/wiki/Data_Dictionary_Guide
@qingl97
qingl97 / gist:44419227ae5eac116ace
Last active June 14, 2024 23:17
Reset local repository to be just like remote repository HEAD

Setting your branch to exactly match the remote branch can be done in two steps:

git fetch origin
git reset --hard origin/master

If you want to save your current branch's state before doing this (just in case), you can do:

git commit -a -m "Saving my work, just in case"
git branch my-saved-work
@qingl97
qingl97 / stackoverflow-1.md
Last active August 29, 2015 14:18
Convert string to integer C

Alternative to atoi() there is better way with using strtol():

Defined in header <stdlib.h>

long strtol( const char *str, char **str_end, int base ); (until C99)
long strtol( const char *restrict str, char **restrict str_end, int base ); (since C99)
long long strtoll( const char *restrict str, char **restrict str_end, int base ); (since C99)

The call atoi(str) shall be equivalent to: (int) strtol(str, (char **)NULL, 10) except that the handling of errors may differ. For atoi(), if the value cannot be represented(not in the format below), the behavior is undefined.

import java.io.IOException;
import java.io.OutputStream;
import javafx.scene.control.TextArea;
public class TextAreaOutputStream extends OutputStream {
private TextArea textArea;
public TextAreaOutputStream(TextArea ta) {
public class Solution {
// only for ASCII characters which takes one byte in storage
public boolean isAnagram(String s, String t) {
if(s == null && t == null)
return true;
if(s == null && t != null)
return false;
if(s != null && t == null)
return false;
if(s.length() != t.length())
public class Solution {
public boolean isPowerOfThree(int n) {
// special case
if(n == 0) return false;
while(n != 1) {
// check if n can be divided by 3, return false if not
if(n%3 != 0) return false;
// take the result as input of next check until it's 1 which means n is power of 3
n = n/3;
}
public class Solution {
public boolean isPowerOfTwo(int n) {
//return solutionOne(n);
//return solutionTwo(n);
return solutionThree(n);
}
private boolean solutionOne(int n) {
// check the result of divition by 2 iteratively
if(n == 0) return false;
public class MinStack {
private List<Integer> data;
private int top_idx;
/** initialize your data structure here. */
public MinStack() {
data = new ArrayList<Integer>();
top_idx = -1;
}