Skip to content

Instantly share code, notes, and snippets.

View dron247's full-sized avatar

dron247 dron247

View GitHub Profile
@dron247
dron247 / FeedsArticles.java
Created January 14, 2019 07:50
Внизу. Пока сдвигаешь, рисуется бэк с крестиком, затем вот тот addPendingItem заменяет элемент на меню, тоесть вместо текста там лэйаут с кнопками, не суть важно
package com.dpcat237.tidinio.ui.fragments.main;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@dron247
dron247 / users.js
Created December 8, 2018 15:26
Студентам: Простая реализация репозитория в ноде, поверх mongo
'use strict'
const bcrypt = require('bcrypt')
const jwt = require('jsonwebtoken')
const Joi = require('joi')
const credentialsSchema = require('../schema/credentials')
module.exports = (database) => {
const collectionName = process.env.DB_USERS_COLLECTION_NAME
const secret = process.env.JWT_SECRET
const saltRounds = Number(process.env.PASSWORD_SALT_ROUNDS)
@dron247
dron247 / setup.js
Created December 7, 2018 15:00
студентам: скрипт для подготовки БД
const mongodb = require('mongodb')
const MongoClient = mongodb.MongoClient
const bcrypt = require('bcrypt')
const connectionString = process.env.DB_CONNECTION_STRING
const dbName = process.env.DB_DATABASE_NAME
const collectionName = process.env.DB_USERS_COLLECTION_NAME
const defaultUserName = process.env.DEFAULT_USER_NAME
const defaultUserPassword = process.env.DEFAULT_USER_PASSWORD
const saltRounds = Number(process.env.PASSWORD_SALT_ROUNDS)
@dron247
dron247 / interface_by_ref.go
Last active September 1, 2018 03:18
How to send data via interface declared channel by ref
package main
import "fmt"
import "time"
// не обязательно явно реализовывать интерфейс, но по хорошему явно надо, ибо поддерживаемость
type testData struct {
name string
}
@dron247
dron247 / git-change-commit-messages.md
Created May 28, 2018 04:25 — forked from nepsilon/git-change-commit-messages.md
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

package com.messapps.carpo.network.custom_converters;
import android.support.annotation.Nullable;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@dron247
dron247 / gist:5dc35a61e9310afd4b2f69a48d26aa33
Created January 29, 2018 13:46 — forked from jacobmoncur/gist:8587185
Gradle file for getting maven dependencies hosted on private github repo
repositories {
mavenCentral()
maven {
url = 'https://github.com/github-username/github-project/raw/master'
credentials {
username 'my-username'
password 'my-password'
}
}
}
private File saveBitmap(Bitmap bmp, String fileName) {
if (bmp == null) return null;
String extStorageDirectory = Environment.getExternalStorageDirectory()
.toString();
OutputStream outStream = null;
File file = new File(extStorageDirectory, fileName + ".png");
if (file.exists()) {
file.delete();
file = new File(extStorageDirectory, fileName + ".png");
@dron247
dron247 / style.xml
Created July 13, 2017 10:51
Full screen dialog style
<style name="YourAlertDialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@color/background_light</item>
<item name="android:titleTextStyle">@color/main_text_dark</item>
<item name="android:textColor">@color/main_text_dark</item>
<item name="colorPrimary">@color/main_light</item>
<item name="colorPrimaryDark">@color/main_light_darker</item>
<item name="colorAccent">@color/main_accent</item>
<item name="android:windowAnimationStyle">@style/DialogAnimation.Window</item>
@dron247
dron247 / git-tag-delete-local-and-remote.sh
Created June 20, 2017 15:50 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName