Skip to content

Instantly share code, notes, and snippets.

View PsyGik's full-sized avatar
🏠
Working from home

Dhanraj Padmashali PsyGik

🏠
Working from home
View GitHub Profile
@PsyGik
PsyGik / scrim-gradient.scss
Created November 28, 2022 15:40 — forked from matthewbeta/scrim-gradient.scss
A simple little SCSS mixin for creating scrim gradients
/*
A simple little SCSS mixin for creating scrim gradients
Inspired by Andreas Larson - https://github.com/larsenwork
https://css-tricks.com/easing-linear-gradients/
*/
@mixin scrimGradient($startColor: $color-black, $direction: 'to bottom') {
$scrimCoordinates: (
@PsyGik
PsyGik / server-preload.js
Created September 9, 2022 11:11 — forked from justjake/server-preload.js
Customizing NextJS for error reporting and Datadog APM (dd-trace) integration. See https://jake.tl/notes/2021-04-04-nextjs-preload-hack
// @ts-check
"use strict"
/**
* Set up datadog tracing. This should be called first, so Datadog can hook
* all the other dependencies like `http`.
*/
function setUpDatadogTracing() {
const { tracer: Tracer } = require('dd-trace')
const tracer = Tracer.init({
@PsyGik
PsyGik / server.js
Created November 24, 2021 08:17 — forked from stramel/server.js
NX Next.js Custom Server
const express = require('express')
module.exports = async function customServer(app, settings, proxyConfig) {
const handle = app.getRequestHandler()
await app.prepare()
const server = express()
if (proxyConfig) {
const proxyMiddleware = require('http-proxy-middleware')
Object.keys(proxyConfig).forEach(context => {
@PsyGik
PsyGik / server.js
Created September 17, 2021 18:02 — forked from leanazulyoro/server.js
Next.js SSR Cache using LRU Cache
const express = require('express')
const next = require('next')
const Cache = require('lru-cache');
const compression = require('compression')
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
@PsyGik
PsyGik / smooth-scrolling.js
Created August 17, 2019 18:30 — forked from drwpow/smooth-scrolling.js
Performant, 60FPS smooth scrolling in Vanilla JavaScript using requestAnimationFrame
/**
* @param {number} yPos Pixels from the top of the screen to scroll to
* @param {number} duration Time of animation in milliseconds
*/
const scrollTo = (yPos, duration = 600) => {
const startY = window.scrollY;
const difference = yPos - startY;
const startTime = performance.now();
const step = () => {
@PsyGik
PsyGik / clipboard.html
Created December 12, 2018 07:04 — forked from LewdEwe-ErikWallace/clipboard.html
This is an example of how to poll the clipboard for changes in an Electron application. See notes in HTML.
<!DOCTYPE html>
<html lang="en">
<head>
<title>My App - Clipboard</title>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' chrome-extension://*;">
</head>
<body>
@PsyGik
PsyGik / nodejs-tcp-example.js
Created June 30, 2018 16:08 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@PsyGik
PsyGik / hero.ts
Created May 18, 2018 08:27 — forked from brennanMKE/hero.ts
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@PsyGik
PsyGik / socket.io-1-0-apache-2.4-ssl.conf
Created February 23, 2018 11:37 — forked from iacchus/socket.io-1-0-apache-2.4-ssl.conf
Set reverse proxy websockets in Apache 2.4 using socket.io 1.0. Needs mod_rewrite module, this version uses SSL. As seen here https://serverfault.com/questions/616370/configuring-apache-2-4-mod-proxy-wstunnel-for-socket-io-1-0
<VirtualHost *:80>
ServerName forum.example.com
Redirect permanent / https://forum.example.com
</VirtualHost>
<VirtualHost *:443>
ServerName forum.example.com
import { TestBed, async, inject } from '@angular/core/testing';
import { HttpClientModule, HttpRequest, HttpParams } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClientFeatureService } from './http-client-feature.service';
describe(`HttpClientFeatureService`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [