Skip to content

Instantly share code, notes, and snippets.

View dackyD's full-sized avatar

Harvey Daclan dackyD

  • Kristiansand, Norway
View GitHub Profile
@dackyD
dackyD / nx-structure-angular-nestjs.md
Created August 23, 2022 14:03 — forked from trungvose/nx-structure-angular-nestjs.md
Nx workspace structure for NestJS and Angular

Nx

https://nx.dev/

Nx is a suite of powerful, extensible dev tools to help you architect, test, and build at any scale — integrating seamlessly with modern technologies and libraries while providing a robust CLI, caching, dependency management, and more.

It has first-class support for many frontend and backend technologies, so its documentation comes in multiple flavours.

Principles

@dackyD
dackyD / css-media-queries-cheat-sheet.css
Created March 13, 2021 17:10 — forked from bartholomej/css-media-queries-cheat-sheet.css
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@dackyD
dackyD / animatedScrollTo.js
Created March 13, 2021 17:09 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
from django.db.models.query import QuerySet
from pprint import PrettyPrinter
def dprint(object, stream=None, indent=1, width=80, depth=None):
"""
A small addition to pprint that converts any Django model objects to dictionaries so they print prettier.
h3. Example usage
>>> from toolbox.dprint import dprint
>>> from app.models import Dummy
>>> dprint(Dummy.objects.all().latest())
@dackyD
dackyD / posting_forms_using_fetch_api.js
Created March 15, 2018 14:55
posting forms using fetch api
const servername = server.value.trim();
const url = `http://${servername}`;
var user = emailid.value.trim();
var pwd = password.value.trim();
const request = new Request(url, {
method: 'POST',
mode: 'no-cors',
"use strict";
class AntiXSS {
static sanitizeInput(str) {
return String(str).replace(/&(?!amp;|lt;|gt;)/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
@dackyD
dackyD / iecache
Last active January 26, 2018 10:49
Prevent node from caching, specially IE
//server side
app.use(function noCache(req, res, next){
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires",0);
next();
});
//client side
$http({
@dackyD
dackyD / ServiceContainer
Created February 19, 2015 08:48
Service Locator inspired by XNA/MonoGame
using System;
using System.Collections.Generic;
public static class ServiceContainer
{
static readonly Dictionary<Type, Lazy<object>> services = new Dictionary<Type, Lazy<object>>();
public static void Register<T>(Func<T> function)
{