Skip to content

Instantly share code, notes, and snippets.

@stepango
stepango / Instagram style EllipsizingTextView
Created September 21, 2015 07:06
Android TextView not support ellipsize if your text fills more than i line. This implementation solved this problem and allow you to use Instagram style end of line mark "[...]"
/*
* Copyright (C) 2011 Micah Hainline
* Copyright (C) 2012 Triposo
* Copyright (C) 2013 Paul Imhoff
* Copyright (C) 2014 Shahin Yousefi
* Copyright (C) 2015 Stepan Goncharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@slightfoot
slightfoot / RestrictedSocketFactory.java
Last active July 5, 2024 04:19
Fix for upload progress monitoring in Android.
import android.util.Log;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
@Amice13
Amice13 / checkIPN.js
Created December 27, 2020 14:18
Перевірка ІПН
const mult = [-1, 5, 7, 9, 4, 6, 10, 5, 7]
const sourceDate = new Date('1899-12-31')
const checkIPN = str => {
const daysSinceBirthday = parseInt(str.slice(0, 5))
let birthday = new Date(sourceDate).setDate(sourceDate.getDate() + daysSinceBirthday + 1)
birthday = new Date(birthday)
const sex = parseInt(str.slice(8,9)) % 2 === 0 ? 'Жінка' : 'Чоловік'
const numbers = str.slice(0,9).split('').map(el => parseInt(el))
const checkSum = numbers.reduce((acc, val, i) => acc + val * mult[i], 0) % 11 % 10