Skip to content

Instantly share code, notes, and snippets.

@NKjoep
NKjoep / current-year.jsp
Created December 20, 2012 10:00
print out the current year within a jsp
<%-- version1: java style --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<% pageContext.setAttribute("currentYear", java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)); %>
Current year is: <c:out value="${currentYear}" />
<%-- version2: JSTL style --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
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 / .bash_profile
Last active May 14, 2021 20:45
My .bash_profile
# Various variables you might want for your PS1 prompt instead
#Time12h="\T"
#Time12a="\@"
PathShort="\w"
#PathFull="\W"
#NewLine="\n"
Jobs="\j"
# Git
source /etc/git-completion.bash
@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 / 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 / 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 / ua-analyzer.jsp
Last active October 27, 2016 00:07
JSP User Agent analyzer
<%@ 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" %>
<c:set var="ua" value="${fn:toLowerCase(header['User-Agent'])}" />
<c:set var="chrome" value="${fn:contains(ua, 'chrome') && !fn:contains(ua, 'msie')}" />
<fmt:formatNumber var="chrome_version" value="${ chrome ? fn:substringBefore(fn:substringAfter(ua, 'chrome/'), '.') : 0}" />
<c:set var="ff" value="${fn:contains(ua, 'firefox') && !fn:contains(ua, 'opera')}" />
<fmt:formatNumber var="ff_version" value="${ ff ? fn:substringBefore(fn:substringAfter(ua, 'firefox/'), '.') : 0}" />
<c:set var="opera" value="${fn:contains(ua, 'opera')}" />
<fmt:formatNumber var="opera_version" value="${opera ?
@NKjoep
NKjoep / myprompt-bash.sh
Last active September 27, 2016 16:58
My Bash Prompt
# Color Reset
Color_Off="\033[0m" # Text Reset
# Regular Colors
Black="\033[0;30m" # Black
Red="\033[0;31m" # Red
Green="\033[0;32m" # Green
Yellow="\033[0;33m" # Yellow
Blue="\033[0;34m" # Blue
Purple="\033[0;35m" # Purple