Skip to content

Instantly share code, notes, and snippets.

View afeish's full-sized avatar
🎯
Focusing

afeish afeish

🎯
Focusing
View GitHub Profile
var iterations = Math.floor(values.length / 8);
var leftover = values.length % 8;
var i = 0;
if ( leftover > 0 )
{
do {
process( values[i++] );
} while ( --leftover > 0 );
}
do {
@afeish
afeish / mavenNotes.md
Created November 10, 2017 07:15 — forked from BDF/mavenNotes.md
Using the maven shade plugin on a Spring Boot application
  • Maven shade with Spring Boot

The goal was to create an uber-jar out of the Spring boot application. Following the directions given at Apache went very smoothly yet when I tried to execute the jar a large number of spring beans were missing and not getting loaded during runtime. For example, one of the beans not getting loaded was 'AutoConfigurationPackages'

jar -tvf name.jar | grep AutoConfigurationPackages showed that the class file was present in tha jar.

@afeish
afeish / OpenWithSublimeText3.bat
Created September 13, 2017 08:35 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@afeish
afeish / getcookiebyname.js
Created June 27, 2017 01:54 — forked from meandmax/getcookiebyname.js
get the cookie value by name if a cookie name exists.
/**
* get cookie by name without using a regular expression
*/
var getCookie = function(name) {
var getCookieValues = function(cookie) {
var cookieArray = cookie.split('=');
return cookieArray[1].trim();
};
var getCookieNames = function(cookie) {
@afeish
afeish / nginx.conf
Created June 5, 2017 02:17 — forked from turtlesoupy/nginx.conf
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@afeish
afeish / Angular seed with sockets example - app.js
Created May 17, 2017 10:30 — forked from laterbreh/Angular seed with sockets example - app.js
Basic ping pong with angular and sockets. This uses an express backend to communicate the emit events.
'use strict';
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.version',
'btford.socket-io'
]).
@afeish
afeish / webpackProgrammaticConfig.js
Created March 15, 2017 01:37 — forked from jwietelmann/webpackProgrammaticConfig.js
File that exports separate webpack configs for frontend and backend
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var deepMerge = require('deep-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
// BEGIN CONFIG TOOLS
// Set up config merging function.
var merge = deepMerge(function(target, source, key) {
@afeish
afeish / cors.js
Created March 7, 2017 13:22 — forked from balupton/cors.js
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);
@afeish
afeish / nodejs-angularjs-common-modules.md
Created March 5, 2017 06:36 — forked from sevcsik/nodejs-angularjs-common-modules.md
Sharing modules between NodeJS and AngularJS

They say that one of the pros of NodeJS is that you use the same language on the back-end and the front-end, so it's easy to share code between them. This sounds great in theory, but in practice the synchronous dependency handling in NodeJS works completely different than any client-side frameworks (which are asynchronous).

Usually that means that you end up copy-pasting your code between your NodeJS sources and your client-side sources, or you use some tool like Browserify, which is brilliant, but they add an extra step in the build process and most likely will conflict with the dependency handling of the framework of your choice (like AnularJS DI). I couldn't look in the mirror if I would call that code sharing.

Fortunately, with a couple of lines of boilerplate code, you can write a module which works in NodeJS and AngularJS as well without any modification.

No globals in the front-end, and dependencies will work. The isNode and isAngular va

@afeish
afeish / gist:d91ec75c5cf9ca152748da9c5d1e01fe
Created February 14, 2017 05:23 — forked from linlihai/gist:10219184
Spring security之No bean named 'springSecurityFilterChain'

近日来自己想基于maven搞一个有多子模块的archetype,就用比较流行的Spring mvc.[archetype] 闲来无事加上Spring security可好? 于是乎加上Spring security之后应用起不来了,日志如下:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:641)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1159)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:282)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)