Skip to content

Instantly share code, notes, and snippets.

View crmaxx's full-sized avatar

Maxim Zhukov crmaxx

  • Russia, Vladimir
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
Используя фреймворк Ruby on Rails необходимо создать веб-приложение, которое содержит:
Модели:
Экскурсия
Категории экскурсии (n-n). Например, историческая, городская, природная, музейная и т.д.
Город экскурсии (1-n).
Для экскурсии существует флаг public, который определяет: выводится ли экскурсия на фронтенде или нет.
Фронтенд:
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
My quick notes on what I did to install Elixir on the Raspberry Pi.
All the info is here, but it's a self guided tour.
# Get Raspbian
http://www.raspberrypi.org/downloads
http://downloads.raspberrypi.org/raspbian_latest
# Copy raspbian.img file to th SD Card
diskutils unmountDisk /dev/disk<numberhere>
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits._
import scala.util.{ Success, Failure }
import akka.actor._
import akka.pattern.{ after, ask, pipe }
import akka.util.Timeout
object LogSearch extends App {
def takeUpToNot[T](pred: (T) => Boolean): Iteratee[T, Seq[T]] = {
def step(ok: Boolean, result: Seq[T])(i: Input[T]): Iteratee[T, Seq[T]] = i match {
case Input.EOF | Input.Empty => Done(result, Input.EOF)
case Input.El(e) =>
if (ok) Cont[T, Seq[T]](i => step(pred(e), result :+ e)(i))
else Done(result, Input.EOF)
}
Cont[T, Seq[T]](i => step(ok = true, Vector())(i))
}
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 / 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