Skip to content

Instantly share code, notes, and snippets.

Avatar

Nguyen Dang Duc scorta

View GitHub Profile
View vietnamese_characters.txt
ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđ
ẠẢÃÀÁÂẬẦẤẨẪĂẮẰẶẲẴÓÒỌÕỎÔỘỔỖỒỐƠỜỚỢỞỠÉÈẺẸẼÊẾỀỆỂỄÚÙỤỦŨƯỰỮỬỪỨÍÌỊỈĨÝỲỶỴỸĐ
View flip_coin_experiment.cpp
// Flip coin until we get 3 consecutive "Tail" or "Head"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <unordered_map>
using namespace std;
enum class coin_state {head, tail};
unordered_map<coin_state, string> coin_state_ref {
View hw3_ducnd.cc
#include <iostream>
#include <algorithm>
#include <iomanip>
#include "json.hpp"
using namespace std;
using json = nlohmann::json;
struct SV
View LevenshteinEditDistance.java
import java.util.ArrayList;
import java.util.Collections;
/**
* Created by Scorta on 09/05/2017.
*/
class LevenshteinEditDistance {
private enum Operation {COPY, DELETE, INSERT, REPLACE}
View gist:58c9728e3f2a104f20c5354b6988a53e
public static string GetAllRegexMatchFromText(string regex, string text)
{
Regex linkParser = new Regex(regex, RegexOptions.Compiled | RegexOptions.IgnoreCase);
string result = string.Empty;
foreach (Match m in linkParser.Matches(text))
result += m.ToString() + "|";
result = result.Remove(result.Length - 1, 1);
View CameraController.cs
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour
{
public float moveSpeed, zoomSpeed;
private Rigidbody rb;
void Start ()
View Get Title and Meta Description tag from an url c#
//First you need to retrieve html source of the given url
//Get Url Title
private string UrlTitle(string url)
{
string source = HtmlSrc(url);
string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
return title;
}
View string.Replace with case-insensitive C#
private static string ReplaceEx(string original, string pattern, string replacement)
{
int count, position0, position1;
count = position0 = position1 = 0;
string upperString = original.ToUpper();
string upperPattern = pattern.ToUpper();
int inc = (original.Length / pattern.Length) *
(replacement.Length - pattern.Length);
char[] chars = new char[original.Length + Math.Max(0, inc)];
while ((position1 = upperString.IndexOf(upperPattern,
View List<string> to string with delimiter C#
List<string> names = new List<string>() { "John", "Anna", "Monica" };
var result = String.Join(", ", names.ToArray());