Skip to content

Instantly share code, notes, and snippets.

View croucha's full-sized avatar
😎

Andre croucha

😎
  • [the cloud]
View GitHub Profile
{
"git.ignoreLegacyWarning": true,
"extensions.ignoreRecommendations": true,
"editor.renderWhitespace": "all",
"editor.insertSpaces": true,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"editor.rulers": [100],
"editor.fontSize": 14,
"editor.useTabStops": true
@croucha
croucha / underscore.move.js
Created November 23, 2016 02:18 — forked from kjantzer/underscore.move.js
Underscore.js Mixin: Move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
/*
_.move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
*/
_.mixin({
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
}
// Define start time
Long start = System.currentTimeMillis();
// Run a bunch of things....
// Define total
Long total = start - System.currentTimeMillis();
// Debug
logger.debug("Query time in milliseconds: " + total);
@croucha
croucha / jquery.version.js
Created April 11, 2016 15:01
jQuery version
if (typeof $!= 'undefined') {
// jQuery is loaded => print the version
console.log('jquery: ' + $.fn.jquery);
console.log('jquery ui: ' + $.ui.version);
}
/**
* Can set a class to last element in a row of elements floating left.
*
* @param {String} list elements (ul li).
* @param {String}
* @returns {undefined}
*/
var setClassToLastElementInRow = function(selector, className) {
var elements = $(selector);
elements.each(function() {
function isScrolledIntoView(element) {
var scrollTop = $(window).scrollTop();
var scrollBottom = scrollTop + $(window).height();
var elementTop = $(element).offset().top;
var elementBottom = elementTop + $(element).height();
return ((elementBottom >= scrollTop) && (elementTop <= scrollBottom) && (elementBottom <= scrollBottom) && (elementTop >= scrollTop));
}
@croucha
croucha / Preferences.sublime-settings
Last active November 8, 2017 01:36
Sublime user settings
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by file type specific settings.
{
"tab_size": 4,
"translate_tabs_to_spaces": true,
"rulers": [100],
"font_size": 10,
"draw_white_space": "all",
"use_tab_stops": false
}
@croucha
croucha / EscapeUtils.java
Last active September 29, 2015 12:16
Util XSS escape test
package your.package.name;
// 2.6
//import org.apache.commons.lang.StringEscapeUtils;
// 3 +
import org.apache.commons.lang3.StringEscapeUtils;
/**
*
* @author croucha
*/
@croucha
croucha / replaceAll.js
Last active August 29, 2015 14:23
Example of having a built in replace all utility using Regex.
(function(app) {
/*----------------------------------------------------------------------------------------------
* UTILILTY INIALIZATION
* This code is executed when the Javascript file is loaded
*--------------------------------------------------------------------------------------------*/
// Ensure util object exists
app.util = app.util || {};
// Create scoped alias to simplify references
@croucha
croucha / gradle.sh
Created June 5, 2015 05:38
Gradle shell script install
#!/bin/bash
# installs to /opt/gradle
# existing versions are not overwritten/deleted
# seamless upgrades/downgrades
# $GRADLE_HOME points to latest *installed* (not released)
gradle_version=2.3
mkdir /opt/gradle
wget -N http://downloads.gradle.org/distributions/gradle-${gradle_version}-all.zip
unzip -oq ./gradle-${gradle_version}-all.zip -d /opt/gradle
ln -sfnv gradle-${gradle_version} /opt/gradle/latest