Skip to content

Instantly share code, notes, and snippets.

View bikrone's full-sized avatar

Hai-Khanh Nguyen bikrone

View GitHub Profile
@bikrone
bikrone / Binding.xaml
Last active August 29, 2015 14:18
Windows phone snippet
<Page DataContext="{StaticResource ViewModel}">
<!-- Normal Binding -->
<TextBlock Text="{Binding Title}"/>
<!-- Binding a property of a propety object -->
<TextBlock Text="{Binding Project.Title}"/>
</Page>
@bikrone
bikrone / List.java
Last active August 29, 2015 14:18
Java snippet
// Array list
List listA = new ArrayList();
listA.add("element 0");
listA.add("element 1");
listA.add("element 2");
//access via index
String element0 = listA.get(0);
String element1 = listA.get(1);
/*
* main.c
*
* Created on: May 22, 2015
* Author: khanh
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
vector<vector<int> > Solution::permute(vector<int> &A) {
vector<vector<int> > listOfPermutations;
vector<int> B;
// get the first permutation
sort(A.begin(), A.end());
// add the first permutation in the list
listOfPermutations.push_back(A);
int n = A.size();
@bikrone
bikrone / Regex
Last active August 29, 2015 14:24
Regex
Html tag Regex
// with attribute
<(\/?\w+)((?:\s+[\w:-]+\s*=?\s*([\"\']?).*?\3)*\s*)\/?>
// without attribute
<(\/?\w+)(?:\s+[\w:-]+\s*=?\s*([\"\']?).*?\2)*\s*\/?>
<\/?(\w+)((\s+[\w:-]+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>
@bikrone
bikrone / StringTest.cs
Created July 6, 2015 11:13
Test string finding performance (KMP, indexOf, Regex) in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace StringTest
{
public static Task<string> downloadUrl(string url)
{
return new Task<string>(() =>
{
Task<string> task;
using (WebClient wc = new WebClient())
{
Console.WriteLine("Start downloading");
task = wc.DownloadStringTaskAsync(url);
@bikrone
bikrone / mysql_size.sql
Created August 8, 2015 06:21
Check mysql database size
SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
@bikrone
bikrone / 0_reuse_code.js
Created October 17, 2016 17:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bikrone
bikrone / Magic keyboard AutoHotkey configuration
Created November 1, 2019 23:39
Magic keyboard AutoHotkey configuration
LWin::LCtrl
; Remap cmd+Tab to Alt+Tab
; Media keys
RWin & F7::SendInput {Media_Prev}
RWin & F8::SendInput {Media_Play_Pause}
RWin & F9::SendInput {Media_Next}
RWin & F10::SendInput {Volume_Mute}
RWin & F11::SendInput {Volume_Down}