Skip to content

Instantly share code, notes, and snippets.

View rajeshpillai's full-sized avatar

Rajesh Pillai rajeshpillai

View GitHub Profile
@rajeshpillai
rajeshpillai / zig-postgres-todo.zig
Last active January 8, 2026 04:51
zig - postgres driver (simple example)
const std = @import("std");
const Io = std.Io;
const MessageType = enum(u8) {
BackendKeyData = 'K',
CommandComplete = 'C',
DataRow = 'D',
ErrorResponse = 'E',
ParameterStatus = 'S',
ReadyForQuery = 'Z',
@rajeshpillai
rajeshpillai / cache.js
Last active March 18, 2025 10:39
Redis Cache for Node.js
// cache/baseCache.js
// This is our abstract base class defining the contract for our cache implementations.
class BaseCache {
async get(key) {
throw new Error('Method "get" must be implemented');
}
async set(key, value, ttl) {
throw new Error('Method "set" must be implemented');
}
console.clear();
function html(strings, ...values) {
// Combine the strings and values into a single string
const combined = strings.reduce((acc, str, i) => acc + str + (values[i] !== undefined ? `§${i}§` : ''), '');
console.log({combined});
// Create a temporary container to hold the HTML string
const container = document.createElement('div');
@rajeshpillai
rajeshpillai / preact-signal-todo-app.js
Last active September 7, 2022 01:39
Preact Signal Todo App Demo
import { render } from "preact";
import { signal, computed } from "@preact/signals";
import { useSignal, useComputed } from "@preact/signals";
const todos = signal([
{ text: "Write my first post", completed: true },
{ text: "Buy new groceries", completed: false },
{ text: "Walk the dog", completed: false },
]);
@rajeshpillai
rajeshpillai / 00.md
Created February 11, 2020 06:48 — forked from maxivak/00.md
Selenium tests on Ruby

Selenium tests on Ruby

Install

gems:

  • gem 'capybara', '2.10.1'
  • gem 'selenium-webdriver', '3.0.3'

Selenium

@rajeshpillai
rajeshpillai / counter.js
Last active October 28, 2019 10:18
useState - Example 1 - Simple state value
const {useState, useEffect} = React;
function Counter() {
const [counter, setCounter] = useState(0);
return (
<div className="content">
<h1 className="count">{counter}</h1>
</div>
);
}
@rajeshpillai
rajeshpillai / canvasjs-theme.js
Created October 17, 2019 00:39
CanvasJS Custom theme
CanvasJS-themes
===============
Adds the ability to use customized themes with CanvasJS. For documentation, refer to http://canvasjs.com
Adding your own theme
=====================
let html = `
<div id="content" class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a data-filter="dashboard" class="nav-link active" href="#">
<span data-feather="home"></span>
Dashboard <span class="sr-only">(current)</span>
</a>
@rajeshpillai
rajeshpillai / tiny-react-createElement-1.js
Created December 17, 2018 11:27
createElement - Version - 1
const TinyReact = (function () {
function createElement(type, attributes = {}, ...children) {
const childElements = [].concat(...children).map(
child =>
child instanceof Object
? child
: createElement("text", {
textContent: child
})
);