Skip to content

Instantly share code, notes, and snippets.

View Suvink's full-sized avatar
🏢
Working from office

Suvin Nimnaka Suvink

🏢
Working from office
View GitHub Profile
@Suvink
Suvink / MetadataFilter.java
Last active April 2, 2024 05:41
Spring Authorization Sample Thread Local Context
public class MetadataFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
try {
String tenantId = request.getHeader('X-Tenant-Id');
TenantContextHolder.getContext().setTenantId(tenantId);
filterChain.doFilter(request, response);
<?xml version="1.0" encoding="utf-8"?>
<profiles version="21">
<profile kind="CodeFormatterProfile" name="wso2_code_style" version="21">
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
@Suvink
Suvink / data_model.json
Created November 12, 2022 06:29
The data model. Ref: Mapping the Employer and Employee: a Visualization based Approach
{
"basic_information": {
"name": "Suvin Kodituwakku",
"birthday": "21/11/1998",
"email": "hello@suvin.me",
"phone_number": "+94771655198",
"home_address": "35B, Kitulampitiya Rd, Kalegana, Galle, Sri Lanka.",
"website": "https://suvin.me",
"external_links": [
"https://github.com/Suvink",
@Suvink
Suvink / hyper.js
Created November 4, 2022 14:32
My personal Hyper configuration. (More at https://hyper.is)
"use strict";
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@Suvink
Suvink / processes.json
Created October 8, 2022 08:17
Git auto deploy script for Express JS with PM2
{
"apps": [
{
"name": "Sample App Name",
"script": "index.js",
"watch": "./",
"log_date_format": "YYYY-MM-DD HH:mm Z"
}
]
}
@Suvink
Suvink / openmp.c
Last active September 30, 2022 19:07
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include <sys/time.h>
#define MATRIX_SIZE 1024
int main()
{
int i,j,k,l,p,q,r;
@Suvink
Suvink / ev3_q_learning_line_follower.py
Created September 7, 2022 13:36
A Line Following Robot built with LEGO EV3 and Q learning.
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor, ColorSensor
from pybricks.parameters import Port
from pybricks.tools import wait
from pybricks.robotics import DriveBase
from random import randint
# Initialize EV3 Brick
@Suvink
Suvink / stripe.js
Created May 22, 2022 05:06
Stripe Success Endpoint Sample
// server.js
//
// Use this sample code to handle webhook events in your integration.
//
// 1) Paste this code into a new file (server.js)
//
// 2) Install dependencies
// npm install stripe
// npm install express
//
@Suvink
Suvink / Stacks
Last active May 16, 2022 06:07
C# Array Operations
//Reverse an array using a stack
public static void Main(string[] args)
{
Console.WriteLine ("Hello Mono World");
int[] arr = {1,3,4,9,8};
Stack myStack = new Stack();
for (int i = 0; i < arr.Length; i = i + 1)
{