Skip to content

Instantly share code, notes, and snippets.

@luigiMinardi
luigiMinardi / tex-colors.md
Last active April 19, 2024 19:20
Github markdown colors (Using Tex and the github MathJax support)

Small warning for everyone that are thinking if using Tex colors is a good idea or not

  • 2023-05-02 - Since a few days ago \colorbox and \fcolorbox are broken and Github did't talk about if it's a temporary thing or if it will not be added back.
    • 2024-01-04 - Since it has not being added back I deduce that it will never be so I removed all mentions to it on the rest of the gist.
  • 2023-09-29 - Tex seems to not work on h1 to h6 anymore (markdown #'s)
    • 2024-01-04 - Now it works again, I'll keep the message for a while to remember that it may change again in the future

As you can se with the above message(s) Tex may not be very stable and may not be an option to you as of the dates expressed above. You can also check other tex problems here.

Github released Tex support and colors* to the markdown and you din't realized

@ankushs92
ankushs92 / SomeInterceptor.java
Last active April 12, 2024 12:23
How to get Path Variables inside a Spring interceptor.[This post assumes that you have an Interceptor registered and set up using XML or Java config]
public class SomeInterceptor extends HandlerInterceptorAdapter{
@Override
public boolean preHandle(final HttpServletRequest request,final HttpServletResponse response,final Object handler)
throws Exception
{
/*Assume the URI is user/{userId}/post/{postId} and our interceptor is registered for this URI.
* This map would then be a map of two elements,with keys 'userId' and 'postId'
*/
final Map<String, String> pathVariables = (Map<String, String>) request
.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
@UnquietCode
UnquietCode / CustomRequestMappingHandlerMapping.java
Created August 23, 2013 20:32
Custom implementation of Spring's RequestMappingHandlerMapping which automatically registers a redirect for the same url with (or without) a trailing slash. This is good in cases where for SEO purposes you want 'url' and 'url/' to resolve to the same page.
package com.sb.server.web;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.view.RedirectView;
@muratcorlu
muratcorlu / slugify_tr.js
Created September 11, 2012 12:46
Javascript Türkçe karakter destekli slugify (url metni oluşturucu)
/**
* Metni url'de kullanılabilir hale çevirir. Boşluklar tireye çevrilir,
* alfanumerik olmayan katakterler silinir.
*
* Transform text into a URL path slug(with Turkish support).
* Spaces turned into dashes, remove non alnum
*
* @param string text
*/
slugify = function(text) {