Skip to content

Instantly share code, notes, and snippets.

View Rich2020's full-sized avatar

Richard Rich2020

View GitHub Profile
@uziassantosferreira
uziassantosferreira / MediaRecorderHelper.java
Created December 12, 2016 12:36
Screen Recording in service android
public class MediaRecorderHelper {
private static final int SENSOR_ORIENTATION_DEFAULT_DEGREES = 90;
private static final int SENSOR_ORIENTATION_INVERSE_DEGREES = 270;
private static final SparseIntArray DEFAULT_ORIENTATIONS = new SparseIntArray();
private static final SparseIntArray INVERSE_ORIENTATIONS = new SparseIntArray();
static {
DEFAULT_ORIENTATIONS.append(Surface.ROTATION_0, 90);
DEFAULT_ORIENTATIONS.append(Surface.ROTATION_90, 0);
@nosix
nosix / Capture.kt
Created September 18, 2016 08:40
Taking a snapshot of the screen for Android (SDK 21) in Kotlin 1.0.3
package xxx
import android.content.Context
import android.graphics.Bitmap
import android.graphics.PixelFormat
import android.hardware.display.DisplayManager
import android.hardware.display.VirtualDisplay
import android.media.ImageReader
import android.media.projection.MediaProjection
import android.util.Log
@umidjons
umidjons / sort-object-properties-by-value.md
Last active January 16, 2024 13:00
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.

@karlgluck
karlgluck / How to Access Data in the Backbuffer in Direct3D 9.cpp
Created January 17, 2014 03:35
This is the code for accessing pixel data from the backbuffer in a D3D9 application. Keywords: LPDIRECT3DSURFACE9 read backbuffer copy back buffer directly access back buffer Direct3D device DirectX 9
void demoExtractBackBufferPixels(LPDIRECT3DDEVICE9 d3d_device) {
// TODO: In your app, add FAILED() macros to check the HRESULTs passed back
// by each of the API calls. I leave these out for clarity.
// Grab the backbuffer from the Direct3D device
LPDIRECT3DSURFACE9 back_buffer = NULL;
d3d_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &back_buffer);
// Get the buffer's description and make an offscreen surface in system memory.
@leandrosilva
leandrosilva / Client.cs
Created October 31, 2010 02:54
Asynchronous Client/Server Socket Example with C# (from MSDN library)
// Asynchronous Client Socket Example
// http://msdn.microsoft.com/en-us/library/bew39x2a.aspx
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
// State object for receiving data from remote device.