Skip to content

Instantly share code, notes, and snippets.

const express = require('express');
const cors = require('cors');
const axios = require('axios');
const app = express();
app.use(cors());
app.use(express.json());
console.log( 'running server')
app.get('/api', async (req, res) => {
@NKjoep
NKjoep / package.json
Last active October 26, 2019 13:33
svg spriter example
{
"name": "spriter",
"version": "0.0.0",
"main": "spriter.js",
"scripts": {
"start": "node spriter.js"
},
"author": "Andrea D. <nkjoep@gmail.com>",
"license": "MIT",
"dependencies": {
  • Make sure you are aware of the problem/feature.
  • Don't be rude, be polite.
  • Give suggestions and make clear why do you think you suggestion is better than the current approach.
  • Don't point out just the bad things, tell about what do you think is great as well.
  • Make it part of your daily workflow. (use github notifications)
  • http://www.dein.fr/2015-02-18-maslows-pyramid-of-code-review.html

pyramid

@NKjoep
NKjoep / express.request.mock.ts
Created June 13, 2018 12:39
Mock ExpressJS request object
function emptyRequest() {
return {
_destroy: undefined,
_read: undefined,
accepted: [],
accepts: undefined,
acceptsCharsets: undefined,
acceptsEncodings: undefined,
acceptsLanguages: undefined,
addListener: undefined,
@NKjoep
NKjoep / ng1-route-sample.js
Created November 15, 2017 14:18
ng1-route-sample.js
$stateProvider
.state('competition', {url: '/:lang/'+ getLocalizedString('URL.COMPETITION'), ...})
@NKjoep
NKjoep / devdocs.io-bookmarklet.js
Last active November 16, 2015 13:50
devdocs.io preferred bookmarklet activator
javascript: (function(){
[
"angular",
"bower",
"css",
"django",
"dom",
"dom_events",
"ember",
"express",
@NKjoep
NKjoep / palindrome-finder.js
Created November 14, 2015 15:03
Javascript Palindromes of Anagrams
/**
* Returns `true` if any of the given string contains a palindrome.
* @param {String} s the string to test
*/
function PalindromeFinder(s) {
//build an array of characters from the string `s`
var chars = s.split('');
//store how many of the same char within the string (so the array)
var charsOccurences = {};
@NKjoep
NKjoep / angular-list-models.html
Created November 13, 2015 14:16
angular list models
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Input Sample</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js"></script>
@NKjoep
NKjoep / postgres-setup.md
Last active August 29, 2015 14:16
PostreSQL Setup

pg_hba.conf:

  host	all	all	0.0.0.0/0	trust

postgres.conf:

  listen="*"
@NKjoep
NKjoep / jsp-date-manipulation-sample.jsp
Created December 16, 2013 15:48
JSP date manipulation sample: increase time give a date sample...
<%@ page contentType="text/plain; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="wp" uri="/aps-core" %>
<%@ taglib prefix="wpsa" uri="/apsadmin-core" %>
<%@ taglib prefix="wpsf" uri="/apsadmin-form" %>
<c:set var="random"><%= java.lang.Math.round(java.lang.Math.random() * 6) %></c:set>
<c:set var="startDate" value="${param.lastStreamTimestamp}" />