Skip to content

Instantly share code, notes, and snippets.

View bqcuong's full-sized avatar

Cuong Bui Quang bqcuong

View GitHub Profile
@bqcuong
bqcuong / genMT.c
Last active June 28, 2018 04:52
oscar_sample.c
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#define Max 1000
void genMatrix(int** a,int n) {
srand(time(NULL));
for(int i=0; i< n; i++) {
for (int j=0; j<n; j++) {
a[i][j] = rand()% 1000;
/**
* 2 for loop: 9952.51 9887.98 9891.36 9950.76 9890.16
* 1 for loop: 9885.17 9888.52 9886.23 9885.01 9882.4
* original :
* 1 for loop: 34841.14 34953.85 34823.9
* 2 for loop: 34842.56 34914.84 34912.07
*/
#include <stdio.h>
#include <stdlib.h>
/*
* i+= 1: 1429.11 1431.84 1430.81 1435.61 1430.51
* i+= 2: 1392.57 1401.44 1399.31 1390.12 1398.40
* i+= 1 & Hung's idea:
* 802.61 802.2 803.17 800.61 820.3
* i+= 2 & Hung's idea:
* 779.11 783.59 783.59 804.49 780.27
*/
#include <stdio.h>
#include <stdlib.h>
@bqcuong
bqcuong / Main.java
Last active November 2, 2018 18:10
Moving Balls_Java Swing
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Diagram diagram = new Diagram(Diagram.WIDTH, Diagram.HEIGHT);
@bqcuong
bqcuong / IO.java
Last active November 11, 2018 04:32
IO Demonstration
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
public class IO {
public static String readFile(File f) throws IOException {
package test;
public class TestGenerics {
public static void main(String[] args) {
Pair<Circle> pair = new Pair<>(1, new Circle(2.0f));
Pair<Person> pair2 = new Pair<>(1, new Person(20));
System.out.println(pair);
System.out.println(pair2);
@bqcuong
bqcuong / ssh_tunnel_rdp
Created December 4, 2018 07:37
Remote Desktop Windows through SSH Tunnel connection
#!/bin/bash
ssh -i ~/.ssh/private_key -N -R 3388:127.0.0.1:3389 -o ServerAliveInterval=120 root@remote_server
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("U6:U50"), Range(Target.Address)) Is Nothing Then
Call Colorize
End If
End Sub
Sub Colorize()
For i = 6 To 50
For j = 1 To 20
If IsEmpty(Cells(i, 21)) = False Then
@bqcuong
bqcuong / TestASTRewrite.java
Last active April 10, 2020 06:24
Edit AST with ASTRewrite
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.UndoEdit;
import org.junit.Assert;
import org.junit.Test;
@bqcuong
bqcuong / build.gradle
Created April 13, 2020 09:26
Gradle copy dependencies
task copyToLib(type: Copy) {
from configurations.testCompile.allArtifacts.files
from configurations.testCompile
into "$buildDir/dependency-libs"
}