Skip to content

Instantly share code, notes, and snippets.

@rayrinaldy
rayrinaldy / compress.py
Created October 30, 2018 02:49
Image Compression with Python
#!/usr/bin/env python
# Author: Ray Rinaldy
# pip install Pillow
# put this script in every image folder that wants to be converted
# run python compress.py
#
# This script will works on .jpg, .jpeg & .png (for png files, it will auto convert to have white background)
import os, glob, PIL, sys
@elizarov
elizarov / DistinctInTimeWindow.kt
Created April 3, 2018 08:25
Channel operator to send distinct time elements in a specific time window
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.*
import kotlinx.coroutines.experimental.selects.*
import java.util.concurrent.*
// operator
fun <T> ReceiveChannel<T>.distinctInTimeWindow(time: Long, unit: TimeUnit): ReceiveChannel<T> = produce {
require(time > 0)
consume {
val source = this@distinctInTimeWindow
@zeroseis
zeroseis / disable-auto-android-file-transfer.md
Created September 14, 2015 17:28
Disable auto start for Android File Transfer
  • Close Android File Transfer
  • Open Activity Monitor and kill “Android File Transfer Agent”
  • Go to where you installed “Android File Transfer.app” (I have it under /Applications)
  • Ctrl+click –> “Show package contents”
  • Go to Contents/Resources
  • Rename “Android File Transfer Agent” to e.g. “Android File Transfer Agent_DISABLED”
  • Then go to “/Users/username/Library/Application Support/Google/Android File Transfer” and again rename the Agent app.
package com.segmentfault.app.view;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.NestedScrollingChildHelper;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
@jannson
jannson / imu.c
Created April 1, 2014 02:51
陀螺仪重力传感器融合代码
//=====================================================================================================
// IMU.c
// S.O.H. Madgwick
// 25th September 2010
//=====================================================================================================
// Description:
//
// Quaternion implementation of the 'DCM filter' [Mayhony et al].
//
// User must define 'halfT' as the (sample period / 2), and the filter gains 'Kp' and 'Ki'.