Skip to content

Instantly share code, notes, and snippets.

View rattanchauhan's full-sized avatar
🎯
Focusing

Rattan Chauhan rattanchauhan

🎯
Focusing
View GitHub Profile
@rattanchauhan
rattanchauhan / Remote.js
Created July 14, 2017 07:56
Remote api simulator in Extjs
Ext.define('Example.util.Remote',{
singleton: true,
requires: [
'Ext.ux.ajax.JsonSimlet',
'Ext.ux.ajax.SimManager'
],
constructor: function () {
Ext.ux.ajax.SimManager.init({
@rattanchauhan
rattanchauhan / Startup.js
Created September 26, 2017 06:59
Sencha event logger
(function() {
// No mouse version
Ext.Component.prototype.fireEvent =
Ext.Function.createInterceptor(Ext.Component.prototype.fireEvent, function() {
if (arguments && arguments[0].indexOf("mouse") === -1 && arguments[0] != "uievent") {
console.log(this.$className, arguments, this);
}
return true;
});})();
@rattanchauhan
rattanchauhan / MainController.js
Last active October 13, 2017 15:13
Securing routes in Extjs 6
Ext.define('App.controller.MainController', {
extend: Ext.app.Controller,
routes: {
'home': {
before: function(action) {
Ext.Ajax.request({
url: Config.endpoints.user,
method: 'GET',
scope: this,
failure: function(data, operation) {
@rattanchauhan
rattanchauhan / Security.js
Last active November 25, 2017 00:45
Extjs Security plugin
/**
* Hides/Disables a component based on the user roles provided and user roles required for a component
* Example usage :
* 1. Default behavior to prevent rendering of component if required role is not present. Suitable for small components like button, textfields and other form controls
* plugins: [
* {
* ptype: 'security',
* roles: ['ROLE_ADMIN', 'ROLE_SUBADMIN', 'APP_ROLE1'],
* }
* ]
@rattanchauhan
rattanchauhan / I18n.js
Last active November 27, 2017 12:04
Extjs I18n (Keys & Translations stored in application itself)
Ext.define('App.common.I18n', {
singleton: true,
alternateClassName: ['I18n'],
requires: [
'App.locale.locale-de',
'App.locale.locale-en',
'App.locale.locale-fr',
'App.locale.locale-it'
],
initLocale: function () {
@rattanchauhan
rattanchauhan / I18n.js
Last active November 27, 2017 15:04
Extjs I18n (Keys & Translations loaded from remote endpoint)
Ext.define('App.common.locale.I18n', {
extend: 'Ext.Base',
singleton: true,
alternateClassName: ['I18n'],
requires: [
'App.store.locale.Translations', // in memory store to keep translations
'App.api.config.Endpoints', // config file with endpoint information
],
initLocale: function (language) {
// STEP 1. find which language to load
@rattanchauhan
rattanchauhan / cntlm_npm.md
Created December 22, 2017 16:50 — forked from triskell/cntlm_npm.md
[Windows 7] CNTLM and NPM behind NTLM proxy

CNTLM and NPM behind NTLM proxy on Windows 7

CNTLM

  • Install CNTLM in a folder where you have full rights to run it as administrator.

  • Open cntlm.ini and fill it :

Username    YOUR_USERNAME
Domain YOUR_DOMAIN
@rattanchauhan
rattanchauhan / AgMaterialModule.ts
Created December 24, 2017 18:27
Angular Material imports
import { NgModule } from '@angular/core';
import {
MatAutocompleteModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatDatepickerModule,
MatDialogModule,
MatExpansionModule,
@rattanchauhan
rattanchauhan / JdbcTemplate
Last active December 9, 2018 12:15
Simple Jdbc Template with connection provider in Java 8
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import org.apache.commons.logging.Log;
@rattanchauhan
rattanchauhan / JdbcTemplate
Last active December 9, 2018 12:15
Simple Jdbc Template with datasource in Java 8
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import app.example.exception.DataAccessException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.function.Consumer;