Skip to content

Instantly share code, notes, and snippets.

View bharathvaj-ganesan's full-sized avatar
🏠
Working from home

Bharathvaj bharathvaj-ganesan

🏠
Working from home
View GitHub Profile
@bharathvaj-ganesan
bharathvaj-ganesan / publish.yml
Created April 20, 2025 12:46
Publish npm package as AWS Codeartifact using Github Action Workflow.
name: Publish NPM Package
on:
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
CODEARTIFACT_DOMAIN: <your-codeartifact-domain>
const colorPalettes = [['#152A3B', '#0D809C', '#F5C03E', '#D63826', '#EBEBD6'],
['#0F4155', '#5399A1', '#8CA96B', '#CB5548', '#E7E6F5'],
['#E8614F', '#F3F2DB', '#79C3A7', '#668065', '#4B3331'],
['#DBE5EC', '#336B87', '#2A3132', '#E94D35', '#EFAC55']];
let num = 10;
let colorThemeIndex = 2;
let queueNumber = [0, 1, 2, 3, 4];
let currentPalette, tileLen;
function draw() {
let size = 500;
function setup() {
if (windowWidth < size) {
size = windowWidth; // p5.js property containing window width
}
createCanvas(size, size); // Creates a new canvas of given size
background(25); // adds color to canvas background
angleMode(DEGREES); // sets p5.js anglemode to degrees
noLoop(); // stop the draw function from executing continuously
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// events.js
const EventEmitter = require('eventemitter3');
const emitter = new EventEmitter();
function subscribe(req, res) {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive'
const evtSource = new EventSource('/events');
evtSource.addEventListener('event', function(evt) {
const data = JSON.parse(evt.data);
// Use data here
},false);
const express = require('express');
const events = require('./events');
const path = require('path');
const app = express();
const port = process.env.PORT || 5001;
const expressWs = require('express-ws')(app);
$(function () {
// if user is running mozilla then use it's built-in WebSocket
window.WebSocket = window.WebSocket || window.MozWebSocket;
const connection = new WebSocket('ws://localhost:8080/githubEvents');
connection.onopen = function () {
// connection is opened and ready to use
};
@bharathvaj-ganesan
bharathvaj-ganesan / polling.js
Created July 29, 2018 10:23
Long Polling client
/* Client - subscribing to the github events */
subscribe: (callback) => {
const pollUserEvents = () => {
$.ajax({
method: 'GET',
url: 'http://localhost:8080/githubEvents',
success: (data) => {
callback(data) // process the data
},
complete: () => {
@bharathvaj-ganesan
bharathvaj-ganesan / nginx.conf
Created May 2, 2018 01:47 — forked from turtlesoupy/nginx.conf
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;