Skip to content

Instantly share code, notes, and snippets.

LayoutInflater factory = LayoutInflater.from(this); // this это context
// final - для того чтобы использовать его в OnClickListener()
final View alertView = factory.inflate(R.layout.layout_add_note, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(alertView);
builder.setTitle(R.string.alert_title_add);
builder.setNegativeButton(R.string.alert_cancel, null);
builder.setPositiveButton(R.string.menu_add, new DialogInterface.OnClickListener() {
@Override
@gordinmitya
gordinmitya / FontTabLayout.java
Created May 24, 2017 12:08 — forked from tmtrademarked/FontTabLayout.java
SImple wrapper class to support fonts in TabLayout
public class FontTabLayout extends TabLayout {
private Typeface typeface;
public FontTabLayout(Context context) {
super(context);
init(context, null);
}
public FontTabLayout(Context context, AttributeSet attrs) {
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT,null);
galleryIntent.setType("image/*");
galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Intent chooser = new Intent(Intent.ACTION_CHOOSER);
chooser.putExtra(Intent.EXTRA_INTENT, galleryIntent);
chooser.putExtra(Intent.EXTRA_TITLE, "title");
val spark = org.apache.spark.sql.SparkSession.builder
.master("local")
.appName("Spark CSV Reader")
.getOrCreate
val df = spark.read
.format("csv")
.option("header", "false") //reading the headers
.option("mode", "DROPMALFORMED")
.schema(StructType(List(
StructField("polarity", IntegerType, nullable = false),
@gordinmitya
gordinmitya / main.cpp
Last active June 25, 2018 17:06
generate binary files with x64 pointers
#include <cstdio>
#include <cstdlib>
#define PTYPE int
#define COUNT 105000 // empiric const to make 40M file
#define BUFFER_SIZE 10
#define VARIATION 500100 // allocate "huge" piece of memory
int main() {
FILE *orderedFile = fopen("ordered.bin", "wb");
@gordinmitya
gordinmitya / container.c
Last active June 25, 2018 16:17
super tiny linux container via copy mechanism with cgroup restrictions, internet between container and host and loop device
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#define STACK_SIZE (1024 * 1024)
#include <sys/types.h>
#include <unistd.h>
//
// ComputerDetailViewController.swift
// Computers
//
// Created by Гоша Бодров on 24.07.2018.
// Copyright © 2018 Гоша Бодров. All rights reserved.
//
import UIKit
class CityCell: BaseCell {
override class var id: String {return "CityCell"}
var checkedImage: UIImageView = {
let iv = UIImageView()
iv.contentMode = .scaleAspectFill
iv.clipsToBounds = true
iv.translatesAutoresizingMaskIntoConstraints = false
iv.heightAnchor.constraint(equalToConstant: 20).isActive = true
iv.widthAnchor.constraint(equalToConstant: 20).isActive = true
iv.isHidden = true
private Bitmap loadFromSvg(String name) {
File file = new File(getDirectory(), name + ".svg");
if (!file.exists()) return null;
Drawable drawable = VectorDrawableCompat.createFromPath(file.getAbsolutePath());
if (drawable == null) return null;
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
@gordinmitya
gordinmitya / Main.java
Created January 24, 2019 16:54
HashSet example with equals and hashCode overriding
package ru.gordinmitya;
import java.util.*;
class Product {
private String name;
private int price;
Product(String name, int price) {
this.name = name;