Skip to content

Instantly share code, notes, and snippets.

@voquanghoa
voquanghoa / cert_convert.sh
Created July 11, 2016 16:59 — forked from jmervine/cert_convert.sh
openssl: convert cert from p7b to crt (or cer)
openssl pkcs7 -print_certs -in old.p7b -out new.crt
# openssl pkcs7 -print_certs -in old.p7b -out new.cer
package voon.truongvan.chines_exercise.model;
import java.util.ArrayList;
/**
* Created by Vo Quang Hoa on 12/22/2015.
*/
public class Question {
private String question;
private ArrayList<String> answers;
@voquanghoa
voquanghoa / SuggestComboBox.cs
Last active March 10, 2024 11:07
C# SuggestCombobox
public class SuggestComboBox : ComboBox
{
#region fields and properties
private readonly ListBox suggestionListBox = new ListBox { Visible = false, TabStop = false };
private readonly BindingList<string> suggBindingList = new BindingList<string>();
private Expression<Func<ObjectCollection, IEnumerable<string>>> propertySelector;
private Func<ObjectCollection, IEnumerable<string>> propertySelectorCompiled;
private Expression<Func<string, string, bool>> filterRule;
public static class ArrayExtension
{
public static void ForEach<T>(this IList<T> list, Action<T> action)
{
foreach (var obj in list)
{
action(obj);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace ModelEasy
{
public class IgnoreInputAttribute : Attribute
{
@voquanghoa
voquanghoa / Thi.md
Last active November 27, 2017 04:58

Bài tập C# cơ bản

Viết một chương trình quản lý sinh viên sử dụng giao diện console (hoặc Window form), có những chức năng sau:

  • Hiển thị menu chọn
  • Nhập dữ liệu từ giao diện
    • Nhập danh sách môn học (Id, Tên môn học, trọng số khi tính điểm trung bình)
    • Nhập danh sách giáo viên (Id, Tên, Quê Quán, Ngày sinh, 1 môn học sẽ dạy ID) --> Nhập Tên, Quê quán, ngày sinh --> chọn môn học --> save
    • Nhập danh sách lớp học(Id, Tên Lớp, Id giáo viên chủ nhiệm) --> Nhập tên lớp --> chọn giáo viên từ danh sách --> save
    • Nhập danh sách sinh viên (Id, Tên, Lớp, Quê Quán, Ngày sinh) --> nhập tên, quê quán, ngày sinh --> chọn lớp từ danh sách --> save
public static void SaveJson<T>(List<T> data, string directory)
{
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
var fileName = $"{typeof(T).Name}s.json";
var filePath = Path.Combine(directory, fileName);
var json = JsonConvert.SerializeObject(data);
@voquanghoa
voquanghoa / ContextExts.kt
Last active March 25, 2019 08:01
Snipet to read file from asset/internal storage on Android with Kotlin
import android.content.Context
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
/**
* Created by Hoa Vo on 1/18/19.
*/
fun Context.readAssetAsString(fileName: String): String = this.assets.open(fileName).use {
String(it.readBytes())
}
int sequenceElement(int[] a, int n)
{
int number = a[0] * 10000 + a[1] * 1000 + a[2] * 100 + a[3] * 10 + a[4];
int beginer = number;
if (n < 5)
{
return a[n];
}
var list = new List<int>();
fun combinationSum(candidates: IntArray, target: Int): List<List<Int>> {
val counts = IntArray(candidates.size){0}
val result = mutableListOf<List<Int>>()
fun gen(i: Int, newTarget: Int){
if(newTarget < 0){
return
}
if(newTarget == 0){
result.add((0 until i).flatMap {x -> (0 until counts[x]).map { candidates[x] } })