Skip to content

Instantly share code, notes, and snippets.

View crmaxx's full-sized avatar

Maxim Zhukov crmaxx

  • Russia, Vladimir
View GitHub Profile
import org.springframework.security.core.GrantedAuthority;
import org.springframework.util.StringUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import java.util.stream.Collectors;
/**
* Строки в роли для Spring Security. В каждой строке может быть несколько ролей через запятую
* Результат: набор ролей, консолидированный из переданных roles
*/
public static Set<GrantedAuthority> toGrantedAuthoritiesDemo(final String[] roles) {
@crmaxx
crmaxx / crypt2.rb
Last active August 29, 2015 14:20
Ruby version of password crypt for SoftPerfect Network Scanner (port from C)
#!/usr/bin/env ruby
# c-prog
# $ ./ns32 {43fa330c-4ec6-4440-a924-bd21b406b0ea} Test654321
# WDOfQ7VONESfJIghgAaD6j4zy0M=
#
# ruby-prog
# => "WDOfQ7VONESfJIghgAaD6j4zy0M="
require 'base64'
require 'securerandom'
@crmaxx
crmaxx / 1.rb
Last active August 29, 2015 14:20
code review
let(:pod) do
pod = Kubeclient::Pod.new
pod.metadata = {}
pod.kind = 'Pod'
pod.apiVersion = 'v1beta1'
pod.id = @id
pod.desiredState = {}
pod.desiredState.manifest = {}
pod.desiredState.manifest.version = 'v1beta1'
pod.desiredState.manifest.containers = [{
@crmaxx
crmaxx / 2.rb
Last active August 29, 2015 14:20
code review
def get_endpoint(id)
endpoint = get_node_config('load-balancer', 'hostname')
begin
ip = Resolv.getaddress(endpoint)
response = open("http://#{ip}", 'HOST' => "#{id}.#{endpoint}").read
rescue StandardError
return false
end
@crmaxx
crmaxx / undertow.scala
Last active January 4, 2019 13:47 — forked from itang/undertow.scala
import io.undertow.Undertow
import io.undertow.server.HttpHandler
import io.undertow.server.HttpServerExchange
import io.undertow.util.Headers
object server extends App {
val server: Undertow = Undertow.builder().addHttpListener(8080, "localhost").setHandler(new HttpHandler() {
override def handleRequest(exchange: HttpServerExchange): Unit = {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain")
exchange.getResponseSender().send("Hello, world!")

MacOS

Build 3059

MD5: 59bab8f71f8c096cd3f72cd73851515d

Rename it to: Sublime Text

Make it executable with: chmod u+x Sublime\ Text

@crmaxx
crmaxx / Preferences.sublime-settings
Last active August 29, 2015 14:21
My Sublime Text config
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "solid",
"theme": "Spacegray Eighties.sublime-theme",
"color_scheme": "Packages/User/base16-eighties.dark (SL).tmTheme",
"dictionary": "Packages/User/russian_english.dic",
"font_face": "InputMonoNarrow Thin",
"font_size": 14.0,
@crmaxx
crmaxx / introrx.md
Last active August 29, 2015 14:21 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@crmaxx
crmaxx / ctlscript.sh
Last active August 29, 2015 14:21
MSF PRO control script with Netscanner
#!/bin/sh
# Disabling SELinux if enabled
if [ -f "/usr/sbin/getenforce" ] && [ `id -u` = 0 ] ; then
selinux_status=`/usr/sbin/getenforce`
/usr/sbin/setenforce 0 2> /dev/null
fi
INSTALLDIR=/opt/metasploit

Moving to ES6 from CoffeeScript

I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.

In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.

While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.

Punctuation

Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio