Skip to content

Instantly share code, notes, and snippets.

andy51002000

Block or report user

Report or block andy51002000

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nodejs-sql.js
const sql = require('mssql')
const config = {
user: '',
password: '',
server: '', // You can use 'localhost\\instance' to connect to named instance
database: '',
options: {
encrypt: true // Use this if you're on Windows Azure
}
View BagOfWord.py
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
corpus = ['The cat sat on the mat', 'The dog sat on the mat', 'The goat sat on the mat']
vectorizer = CountVectorizer(lowercase=True, analyzer='word', binary=False)
representation = vectorizer.fit_transform(corpus)
representation_df = pd.DataFrame(data = representation.toarray(), columns=sorted(vectorizer.vocabulary_.keys()))
@andy51002000
andy51002000 / Get-Random-Filename.ps1
Last active Jun 17, 2019
Get Random Filename in powershell
View Get-Random-Filename.ps1
function Get-RandomFilename {
[IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName() )
}
Get-RandomFilename
# Result ------------------------------
# PS C:\Windows\system32> Get-RandomFilename
# cbzivvcs
#
@andy51002000
andy51002000 / PowerShellJson.ps1
Created Jun 16, 2019
Query Azure resource information and access the json output
View PowerShellJson.ps1
$appUserPWD= $(az webapp deployment list-publishing-profiles --name $appname --resource-group $resouceGroup --query '[0].{userPWD:userPWD,userName:userName}' -o json | ConvertFrom-Json )
$appUserPWD
$appUserPWD.userPWD
# Result >
# PS C:\Windows\system32> $appUserPWD
#
# userName userPWD
# -------- -------
# $webSite-botapp-123fz3m6x4 hm7lwb8rqpARtLki9uz5Thx6oFadERGWaX1vgjXQ1eyCrdT
@andy51002000
andy51002000 / listfile.js
Created Jun 15, 2019
Node.js list all files in a directory
View listfile.js
const testFolder = './tests/';
const fs = require('fs');
fs.readdirSync(testFolder).forEach(file => {
console.log(file);
});
@andy51002000
andy51002000 / azureBlobHelper.js
Created Dec 18, 2018
Create Container on Azure Blob
View azureBlobHelper.js
var azure = require('azure-storage');
var blobService = azure.createBlobService("andytestapp",
"5gs4i123123adasd23423423412312323423424234234234234Mg==");
module.exports = {
createContainerIfNotExists(containerName) {
return new Promise(function(resolve, reject) {
blobService.createContainerIfNotExists(containerName, {
publicAccessLevel: 'blob'
@andy51002000
andy51002000 / Base64EncodeInSize44.cs
Last active Dec 7, 2018
Base64 Encoding In Limited Size 44
View Base64EncodeInSize44.cs
using System;
using System.Text;
using System.Security.Cryptography;
public class Program
{
public static void Main()
{
byte[] SHA256Data = Encoding.UTF8.GetBytes("12345678");
SHA256Managed Sha256 = new SHA256Managed();
byte[] Result = Sha256.ComputeHash(SHA256Data);
@andy51002000
andy51002000 / MVVM.cs
Created Nov 2, 2018 — forked from heiswayi/MVVM.cs
C# MVVM common classes in a single file. Example of usage: https://heiswayi.github.io/2016/mvvm-common-classes-in-single-file
View MVVM.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Windows;
using System.Windows.Input;
namespace HeiswayiNrird.MVVM.Common
{
@andy51002000
andy51002000 / makeHttpRequest.cs
Last active Oct 31, 2018
Make Http request to FB to get access token
View makeHttpRequest.cs
public static async Task<string> GetFacebookProfileName(string accessToken)
{
var uri = GetUri("https://graph.facebook.com/v2.6/me",
Tuple.Create("fields", "id,name"),
Tuple.Create("access_token", accessToken));
var res = await FacebookRequest<FacebookProfile>(uri);
return res.Name;
}
@andy51002000
andy51002000 / app.xaml.cs
Last active Oct 28, 2018
Overrid OnBackgroundActivated to communicate with win32
View app.xaml.cs
protected async override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{
base.OnBackgroundActivated(args);
if (args.TaskInstance.TriggerDetails is AppServiceTriggerDetails)
{
appServiceDeferral = args.TaskInstance.GetDeferral();
args.TaskInstance.Canceled += OnTaskCanceled; // Associate a cancellation handler with the background task.
You can’t perform that action at this time.