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
@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.
View [deep_link]app.cs
@andy51002000
andy51002000 / index.js
Last active Sep 1, 2018
SQS Lambda poll code
View index.js
var AWS = require('aws-sdk');
exports.handler = function(event, context, callback) {
var sqs = new AWS.SQS({ apiVersion: "2017-12-29" });
var queueURL = "https://sqs.us-east-1.amazonaws.com/1234567890/Tasks";
var params = {
AttributeNames: ["SentTimestamp"],
View policy_for_home.json
{
"Sid": "Stmt1532888889",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mywebsite/home.html",
"Condition": {
"StringLike": {
"aws:Referer": "http://mywebsite.s3-website-us-east-1.amazonaws.com/index.html"
},
View home.html
<h2>Hello! Congratulation</h2></body></html>
You can’t perform that action at this time.