Skip to content

Instantly share code, notes, and snippets.

@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
@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" %>
@NKjoep
NKjoep / fill-form-bookmarklet.js
Created April 3, 2013 13:18
Bookmarklet: Fill That Form with Random Numbers
javascript: (function () {function fill(input) {if ((input.tagName == 'input' && (input.type != 'hidden' && input.type != 'submit' && input.type != 'image')) || (input.tagName == 'textarea')) {if (input.value == null || input.value.length==0) {input.value = Math.floor(Math.random() * 9999999)}}}var inputs = document.getElementsByTagName("input");for (var i = 0; i < inputs.length; i++) {fill(inputs[i]);}var inputs = document.getElementsByTagName("textarea");for (var i = 0; i < inputs.length; i++) {fill(inputs[i]);}})();
@NKjoep
NKjoep / view-source.bookmarklet
Last active December 16, 2015 19:59
Bookmarklet for quick "view-source". Works with Webkit/FF
javascript: (function () { window.open("view-source:"+window.location.href, '_blank'); })();
@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 / 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}" />
@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 / 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 / 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 / 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",