Skip to content

Instantly share code, notes, and snippets.

View binrebin's full-sized avatar
🏠
20 days to release

Bin binrebin

🏠
20 days to release
View GitHub Profile
@Keep
data class CommentsResponse(
@SerializedName("comments") private val commentsResponse: List<CommentResponse>) {
fun toComments() = commentsResponse.map { it.toComment() }
fun findChildren(cid: String): List<Comment> {
val comments = toComments()
val groups = comments
.sortedWith(compareBy({ it.parentid }, { it.comid }))
@binrebin
binrebin / gist:b661e4947b33596f2ddb6f908792948d
Created October 1, 2020 18:03 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

imports....
class BasicProfileViewModel @Inject constructor(private val basicProfileUseCase: BasicProfileUseCase,
private val getUserUseCase: GetUserUseCase) : ViewModel() {
private val _profileDataState = MutableLiveData<DataState<BasicProfileModel>>()
val profileDataState: LiveData<DataState<BasicProfileModel>>
@binrebin
binrebin / BasicProfileFragment.kt
Last active April 29, 2020 10:19
basic profile fragment
imports .....
class BasicProfileFragment : DaggerFragment() {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
private lateinit var basicProfileViewModel: BasicProfileViewModel
private var filterEventHasBeenHandled = false
companion object {
const val FILTER_EVENT_HANDLED = "filterEventHasBeenHandled"
e: java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type: ErrorScope{Error scope for class <ERROR CLASS> with arguments: org.jetbrains.kotlin.types.IndexedParametersSubstitution@2fce90ef}
@binrebin
binrebin / example.conf
Created December 28, 2019 18:22 — forked from hgn/example.conf
Simple Python aiohttp Server with Configuration Parsing and Logging
server_addr = "127.0.0.1"
server_port = 8888
# debug level, can be debug, error, info, ...
loglevel = "debug"
paths = {
"route_set" : "/",
"interface_get" : "/",
@binrebin
binrebin / docker-config.yml
Created September 5, 2019 11:00 — forked from etsuo/docker-config.yml
docker-config.yml MongoDB replica set
version: "3"
services:
mongo1:
container_name: cf_mongo1
image: mongo:latest
ports:
- "127.0.0.1:37001:27017"
networks:
- backend
command: |
@binrebin
binrebin / postman_install.sh
Created August 25, 2019 09:07 — forked from cagcak/postman_install.sh
Postman install Ubuntu 18.04
#!/bin/bash
# Get postman app
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
sudo ln -s /opt/Postman/Postman /usr/bin/postman
#Create a Desktop Entry
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8