Skip to content

Instantly share code, notes, and snippets.

@nmeylan
nmeylan / Js redirect to
Last active January 31, 2017 02:31
Rails redirect_to with javascript
def js_redirect_to(path)
render js: %(window.location.href='#{path}') and return
end
@nmeylan
nmeylan / serializeJSON
Last active August 29, 2015 14:00
jQuery serialize form in JSON
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
//JSON
$.fn.serializeJSON = function () {
var json = {};
jQuery.map($(this).serializeArray(), function (n, i) {
if(n['name'].endsWith('[]')){
if(json[n['name']] === undefined)
@nmeylan
nmeylan / Spring MVC ControllerInterceptor
Created May 23, 2014 12:10
Spring MVC, controller interceptor
import java.lang.annotation.Annotation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
@nmeylan
nmeylan / highlight_search.js
Last active August 29, 2015 14:05
A mac osx like highlight search. Override ctrl + f browser behaviour.
function highlight_search() {
var search_box = $('#highlight_search');
var input = search_box.find('input');
search_box.keydown(function (e) {
highlight_result(e, input)
});
$('html').keydown(function (e) {
var ctrl = e.ctrlKey, cmd = e.metaKey, f3_key = 114, f_key = 70;
if (e.keyCode === f3_key || ((ctrl || cmd) && e.keyCode === f_key)) {
e.preventDefault();
@nmeylan
nmeylan / gist:fb603e3868392ff2237a
Last active August 29, 2015 14:07
Environment argument Shoes (osX)
JRUBY_OPTS='-J-XstartOnFirstThread'
JRUBY_OPTS=' -J-XstartOnFirstThread' ruby app.rb
@nmeylan
nmeylan / gist:a2366daf24ea47a13aba
Created October 22, 2014 07:00
Qt binding installation OSX 10.10
brew install qt
# Install ruby version with following options.
CC=clang CONFIGURE_OPTS="--with-gcc=clang --enable-shared" rvm install 'version'
gem install qtbindings
# It's work
@nmeylan
nmeylan / gist:efb1acd58a9e088483cb
Last active August 29, 2015 14:08
MS office progess bar
Sub AddProgressBar()
On Error Resume Next
With ActivePresentation
sHeight = .PageSetup.SlideHeight - 60
sImage1Path = ActivePresentation.Path + "\Image1.png"
sImage2Path = ActivePresentation.Path + "\Image2.png"
sImage3Path = ActivePresentation.Path + "\Image3.png"
n = 0
j = 0
For i = 1 To .Slides.Count
@nmeylan
nmeylan / qt_app.rb
Created November 3, 2014 16:48
Ruby qt binding sample app (graphics view/scene)
# Author: Nicolas Meylan
# Date: 22.10.14
# Encoding: UTF-8
# File: qt_app.rb
require 'Qt'
class QtApp < Qt::Widget
# Constants
MINERAL_COLORS = {A: '#006BFF', B: '#00ff45', V: '#e4e4e4', AGENT: '#A1499E'}
@nmeylan
nmeylan / beautiful_log
Created December 4, 2014 16:54
Gitconfig beautiful log
hist = log --pretty=format:\"%C(yellow)%h %C(cyan)%ad %C(white)| %s%C(green bold)%d %Creset%C(magenta)[%an]\" --graph --date=rfc
@nmeylan
nmeylan / git_conf_aliases
Created December 4, 2014 17:00
Git config aliases
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%C(yellow)%h %C(cyan)%ad %C(white)| %s%C(green bold)%d %Creset%C(magenta)[%an]\" --graph --date=rfc
type = cat-file -t
dump = cat-file -p