Skip to content

Instantly share code, notes, and snippets.

@jasonheecs
jasonheecs / gist:eccc71acbebf77835944f61a15da640a
Created July 17, 2026 05:59
csv_dataset_snaic_week5.csv
id,label,subject,text,Priority
1,account_access,Guest access permissions wrong,Guest access isn't respecting the permission levels I set.,P3
2,account_access,PIN keeps locking the account after a couple tries,My PIN entry locks the account after only a couple attempts. This seems way too sensitive. I got charged for this month but cant even access the service because the account keeps locking me out.,P3
3,account_access,Shared account not recommended warning missing,I created a shared account for the team but there was no warning that shared accounts are security risks.,P3
4,account_access,Payment info required for free account,You're asking for payment information even though I only want the free tier. Why do you need my card?,P4
5,account_access,Fingerprint entry stopped working after the update,Since the latest update my fingerprint authentication no longer works and I don't remember my credentials.,P3
6,account_access,Certificate pinning missing,HTTPS certificate pinning not implemented.,P4
7,account_acce
@jasonheecs
jasonheecs / FooTest.kt
Created September 7, 2022 18:51
Sample Unit test illustrating how to test log4j2 loggers using a custom appender
package com.example
import com.example.appender.TestAppender
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.core.LoggerContext
import org.apache.logging.log4j.core.config.Configuration
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
@jasonheecs
jasonheecs / Foo.kt
Created September 7, 2022 18:06
Foo class used to illustrate testing of a log4j logger
package com.example
import mu.KotlinLogging
class Foo {
private val logger = KotlinLogging.logger {}
fun bar() {
logger.error("this is a test log message")
}
@jasonheecs
jasonheecs / log4j2-test.xml
Last active September 7, 2022 09:04
Sample configuration to inject a TestAppender into log4j2
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="LOG_PATTERN">
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
@jasonheecs
jasonheecs / TestAppender.kt
Last active September 13, 2022 17:24
TestAppender used for unit testing in log4j2 loggers
package com.example.appender
import org.apache.logging.log4j.core.Filter
import org.apache.logging.log4j.core.Layout
import org.apache.logging.log4j.core.LogEvent
import org.apache.logging.log4j.core.appender.AbstractAppender
import org.apache.logging.log4j.core.config.Property
import org.apache.logging.log4j.core.config.plugins.Plugin
import org.apache.logging.log4j.core.config.plugins.PluginAttribute
import org.apache.logging.log4j.core.config.plugins.PluginElement
let heartBeatActivated = false;
class HeartBeat {
constructor() {
document.addEventListener('DOMContentLoaded', () => {
this.initHeartBeat();
});
}
initHeartBeat() {
this.lastActive = new Date().valueOf();
const sessionTimeoutPollFrequency = 5;
function pollForSessionTimeout() {
let request = new XMLHttpRequest();
request.onload = function (event) {
var status = event.target.status;
var response = event.target.response;
// if the remaining valid time for the current user session is less than or equals to 0 seconds.
if (status === 200 && (response <= 0)) {
@jasonheecs
jasonheecs / session_timeout_controller.rb
Last active September 5, 2024 21:06
SessionTimeoutController
class SessionTimeoutController < Devise::SessionsController
prepend_before_action :skip_timeout, only: [:check_session_timeout, :render_timeout]
def check_session_timeout
response.headers["Etag"] = "" # clear etags to prevent caching
render plain: ttl_to_timeout, status: :ok
end
def render_timeout
if current_user.present? && user_signed_in?
@jasonheecs
jasonheecs / routes.rb
Created March 11, 2021 07:44
new routes for session timeout
devise_scope :user do
get "/check_session_timeout" => "session_timeout#check_session_timeout"
get "/session_timeout" => "session_timeout#render_timeout"
end
@jasonheecs
jasonheecs / user.rb
Created March 11, 2021 07:15
Implementing timeoutable on a Devise User model
class User < ActiveRecord::Base
devise :timeoutable
end