Skip to content

Instantly share code, notes, and snippets.

View yxy's full-sized avatar

BBB yxy

  • gggg
View GitHub Profile
@anthonynsimon
anthonynsimon / aiohttp_trace.py
Last active September 14, 2023 11:51
aiohttp tracing
import aiohttp
def request_tracer(results_collector):
"""
Provides request tracing to aiohttp client sessions.
:param results_collector: a dict to which the tracing results will be added.
:return: an aiohttp.TraceConfig object.
:example:
@docPhil99
docPhil99 / macFFmpeg.md
Last active March 1, 2024 12:31
Mac webcam FFmpeg

#Capture and stream a webcam To capture using the iSight camera on a Mac, or infact any other webcam connected to the Mac, we can use FFmpeg. First get a list of the devices installed.

ffmpeg -f avfoundation -list_devices true -i "" 

This will list the aviable video and audio devices.

The below will capture at 30fps and the set video size to a file. ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i "0:none" out.avi

@luke14free
luke14free / sample_usage.py
Last active October 26, 2016 18:36
Simple type checked objects in Python
#!/usr/bin/env python
from type_checked_entities import entity_factory
Giraffe = entity_factory( # let's define what is a giraffe!
"giraffe",
name=str, # my name is a string
age=float, # my age is an int
eats=object, # I eat pretty much everything.
)
@tbarbugli
tbarbugli / How to build a notification feed.md
Last active October 17, 2021 20:13 — forked from tschellenbach/notify_tut.md
How to build a notification feed using Stream

How to build a notification feed using Stream

Introduction

In this tutorial we are going to show how easy it is to build a notification feed using GetStream.io. First of all, let's quickly introduce you to our fictional example app. It's called bug-your-friends.com and allows you interact with your friends, ping them, follow them or poke them. Here's a quick list of example interactions:

  • poke another user (eg. Thierry pokes Alessandra)
  • follow a user (eg. Tommaso follows Iris)
  • ping a user (eg. Josie pings Carolina)

Whenever a user is part of one of these interactions, we want to update his notification feed, update the number of unseen and unread

@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;