Skip to content

Instantly share code, notes, and snippets.

View icchan's full-sized avatar

Ian icchan

View GitHub Profile
@icchan
icchan / shield_prompt.py
Last active September 2, 2024 23:32
Demonstrates how to call the Azure AI Content Safety Shield Prompt API to detect jailbreak, indirect and direct prompt injections
"""" This script demonstrates how to use the Content Safety API Shield Prompt """
import os
from pprint import pprint
from azure.ai.contentsafety import ContentSafetyClient
from azure.core.credentials import AzureKeyCredential
from azure.core.exceptions import HttpResponseError
from azure.core.rest import HttpRequest, HttpResponse
@icchan
icchan / tesla-inventory.py
Last active September 2, 2024 04:56
A basic script read Tesla's current Australian inventory. Intended to set up a price alert for myself.
"""" Pulls car data from Tesla inventory API """
from datetime import datetime
import json
import requests
from pprint import pprint
import argparse
def get_cars(model='m3', condition='used', region='NSW'):
""" Get cars from Tesla inventory API """
@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;