Skip to content

Instantly share code, notes, and snippets.

View icchan's full-sized avatar

Ian icchan

View GitHub Profile
@icchan
icchan / ad-application-token-for-graph-api.js
Last active February 8, 2019 03:06
Sample Node for obtaining an application token to call Microsoft Graph API
var request = require('request');
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");
// required inputs
var tenant = ''; // tenant id
var clientId = ''; // application id
var secret = ''; // application password
// prepare http request
var url = 'https://login.microsoftonline.com/' + tenant + '/oauth2/v2.0/token';
@icchan
icchan / test.html
Created February 4, 2019 04:45
Hello World Html
<html>
<head>
<style>
h1 {
font-family: Calibri;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
@icchan
icchan / test.md
Created February 4, 2019 04:44
Hello World Markdown

Hello World

This is content converted from Markdown!

Here's a JSON sample:

{
  "foo": "bar"
}
@icchan
icchan / AsymmetricKeySignature.java
Last active March 4, 2016 09:50
Some example functions on how to do digital signatures, both asymmetric and symmetric.
package net.bubblemix.signature;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
@icchan
icchan / LoggerFilter.java
Created February 19, 2016 10:19
A filter for logging the HTTP header and body, but allowing it to be read again in the next filter, servlet or controller
package net.bubblemix;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
package main
import (
"fmt"
"golang.org/x/crypto/ripemd160"
)
func main() {
hasher := ripemd160.New()
hasher.Write([]byte("The quick brown fox jumps over the lazy dog"))
@icchan
icchan / ian-svg.html
Last active November 20, 2015 03:05
A svg of the ian hair logo
<html>
<head>
<style>
#ian {
position: absolute;
bottom: 0px;
height: 400px;
}
body {
background: #eef;
@icchan
icchan / EmbeddedCassandraTest.java
Created November 17, 2015 07:10
Embedded Cassandra Spring JUnit Test
package net.bubblemix.test;
import org.cassandraunit.spring.CassandraDataSet;
import org.cassandraunit.spring.CassandraUnitTestExecutionListener;
import org.cassandraunit.spring.EmbeddedCassandra;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.http.HttpStatus;
@icchan
icchan / RegexCardValidator.java
Last active May 16, 2024 04:13
Java Credit Card Number Validator
package net.bubblemix.cardcheck;
/**
* Validator for credit card numbers
* Checks validity and returns card type
*
* @author ian.chen
*/
public class RegexCardValidator {