Skip to content

Instantly share code, notes, and snippets.

View lekhanh1234's full-sized avatar

Khanh Le lekhanh1234

View GitHub Profile
@lekhanh1234
lekhanh1234 / bash.md
Last active October 26, 2018 08:16
bash basic

Learn at this tutorial http://www.shellscript.sh/

1.HelloWorld

The first line

#!/bin/sh
echo 'hello world'

what is #!/bin/sh means?

  • It likely declare a environment to run the below shell.

Example to using Graph API (facebook API) to get an picture profile of someone.

The first one ís html file

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>

set space for a block of code

:4,9s/^/   /

It means, from line 4 to line 9, search for ^ and replace by / /

Go to a block of code using

shift 0 : move cursor to the end of block
shift 9 : move cursor to the head of block

Fix Error cannot connet to sqlexpress

  • goto service
  • find Sql Server Agent
  • turn it on

Create database Company with:

  • Employee(Id, Name, FullName, BirthDay, Gender, Address, Salary, LeaderId, DepartmentId)

– Department(DepartmentId, DepartmentName, Leader)

function confirm_request(){
return new Promise(function(fulfill, reject){
dom = $(".phl")[1];
confirm_buttons = $(dom).find('button:contains("Confirm")')[0];
$(confirm_buttons).click();
setTimeout(function(){
fulfill();
}, 3000);
})
.then(function(){
@lekhanh1234
lekhanh1234 / script.py
Created March 10, 2017 03:36
Convert column to text
import pandas as pd
import io
content = open("test5.iob2.txt", "r").read().strip()
result = content
lines = result.split("\n\n")
lines = [pd.read_table(io.StringIO(line.decode("utf-8")), names=["text", "tag"]) for line in lines]
import pandas as pd
import numpy as np
df = pd.DataFrame(
{
'key': ['B_W', 'B_W', 'I_W', 'B_W', 'B_W', 'B_W', 'I_W', 'I_W', 'B_W'],
'text': ['a', 'b', 'b', 'd', 'e', 'f', 'f', 'f', 'g']
}
)
mask = df[df["key"] == "B_W"].index
@lekhanh1234
lekhanh1234 / README.md
Created May 25, 2017 07:46
Example of README

Dillinger

N|Solid

Dillinger is a cloud-enabled, mobile-ready, offline-storage, AngularJS powered HTML5 Markdown editor.

  • Type some Markdown on the left
  • See HTML in the right
  • Magic
import pandas as pd
df = pd.read_excel("input.xlsx")
df = df.groupby(["A", "B"])["A"].count().reset_index(name="Count")
df_sum = df.groupby('B').sum().reset_index()
df1 = df.groupby('B').head(2)
df1 = df1.groupby('B')['A'].apply(lambda x: "%s" % ', '.join(x)).reset_index(name='Top')
df1.merge(df_sum)
//////////////////////
var str = "Uppercase this string (eXcEpT ThIs) and (ThIS)";
reg = /(\(.*?\))/g;
function toUpperCase(str){
return str.toUpperCase();
}
function doubling(str){
return str+str;
}