Skip to content

Instantly share code, notes, and snippets.

View framon's full-sized avatar

Fábio Ramon framon

  • Feira de Santana
View GitHub Profile
// Prevent the backspace key from navigating back.
$(document).unbind('keydown').bind('keydown', function (event) {
var doPrevent = false;
if (event.keyCode === 8) {
var d = event.srcElement || event.target;
if ((d.tagName.toUpperCase() === 'INPUT' &&
(
d.type.toUpperCase() === 'TEXT' ||
d.type.toUpperCase() === 'PASSWORD' ||
d.type.toUpperCase() === 'FILE' ||
public final class Lazy<T> {
private volatile T value;
public T getOrCompute(Supplier<T> supplier) {
final T result = value; // Just one volatile read
return result == null ? maybeCompute(supplier) : result;
}
private synchronized T maybeCompute(Supplier<T> supplier) {
if (value == null) {
value = requireNonNull(supplier.get());
}
pkill gvfs; GVFS_DEBUG=all GVFS_SMB_DEBUG=10 `find /usr/lib* -name 'gvfsd'` &> /tmp/log.txt
// Credits: Adam's answer in http://stackoverflow.com/a/20786262/69362
// Paste this in browser's console
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeError - fired when an error occurs during transition.');
@framon
framon / angular.jsp
Last active August 29, 2015 14:09 — forked from wvuong/angular.jsp
<script>
// inject inlined constants
angular.module('app.constants', [])
.constant('contextPath', '${pageContext.request.contextPath}');
</script>
@framon
framon / application.xml
Created September 17, 2014 11:35
Spring merge props with parent
<beans>
<bean id="parent" abstract="true" class="example.ComplexObject">
<property name="adminEmails">
<props>
<prop key="administrator">[email protected]</prop>
<prop key="support">[email protected]</prop>
</props>
</property>
</bean>
<bean id="child" parent="parent">
#Conceitos sobre arquitetura
http://randomactsofarchitecture.com/2012/11/20/should-software-architects-write-code/
http://www.infoq.com/articles/brown-are-you-a-software-architect
http://www.joelonsoftware.com/items/2006/09/01.html
#Apresentação do Twitter sobre otimizações da JVM
http://www.slideshare.net/aszegedi/everything-i-ever-learned-about-jvm-performance-tuning-twitter
#Livros
Recomendações: http://pinterest.com/while42/pragmatic-programmer/
$('.target').on('dragover', function(event){
event.preventDefault();
});
$('.target').on('drop', function(event){
var id = event.originalEvent.dataTransfer.getData('id');
});
$('.souce').on('dragstart', function(event){
var id = $(this).attr('id');
@framon
framon / detectidle.js
Created November 12, 2013 15:02
Basic jQuery to detect idle time. TODO: Improve
idleTime = 0;
$(document).ready(function () {
//Increment the idle time counter every minute.
var idleInterval = setInterval(timerIncrement, 60000); // 1 minute
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
@framon
framon / log.js
Created November 11, 2013 15:59
Javascript Log Output
var debug = true,
LOG = debug ? console.log.bind(console) : function () {};