Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdint.h>
#include <string.h>
// 本质上是一个“环状”俄罗斯方块,以及每一层只有一个中心是实心的方块
// 状态共 80bit: 15bit + 60bit + 5bit
// 15bit: 积木有没有被使用
// 60bit: 对应位置有没有填满,为 12*5 点阵
// 5bit: 内层有没有被填满
// 状态转移: 找到最左下角的空位,尝试放置下一块积木
@nareix
nareix / webrtc-sendrecv.txt
Last active December 17, 2018 08:53
webrtc VideoSendStream/VideoReceiveStream procedure
VideoSendStream
VideoSendStreamImpl::VideoSendStreamImpl
video_stream_encoder_->SetSink register VideoSendStreamImpl::OnEncodedImage callback (output)
VideoSendStream::SetSource
video_stream_encoder_->SetSource(source, degradation_preference);
register rtc::VideoSourceInterface<VideoFrame>* source (input)
VideoStreamEncoder procedure
OnFrame: encoder_queue_.PostTask(EncodeTask)
in task: EncodeVideoFrame() video_sender_.AddVideoFrame(frame)
@nareix
nareix / gist:c94db8aad2123612dca0
Last active March 26, 2017 19:50
use qemu run u-boot
// qemu run arm
// https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=112259
qemu-system-arm -kernel kernel-qemu-4.1.7-jessie -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda 2015-09-24-raspbian-jessie.img
// qemu machine list
Supported machines are:
akita Akita PDA (PXA270)
borzoi Borzoi PDA (PXA270)
canon-a1100 Canon PowerShot A1100 IS
@nareix
nareix / promise.lua
Last active April 17, 2019 12:04
Promise in lua
local P = {}
P.reject = function (err)
return P.new(function (fulfill, reject)
reject(err)
end)
end
P.resolve = function (r)
return P.new(function (fulfill, reject)
@nareix
nareix / PatchingWithGitDiff.sh
Last active August 29, 2015 14:20
Patching with git diff
# Source: http://tamsler.blogspot.com/2009/02/patching-with-git-diff.html
# If you want to create a patch file via "git diff"
# that can be applied using "patch -p0 < patchfile" use the following command:
git diff --no-prefix > patchfile
# then apply the patch
patch -p0 < patchfile
@nareix
nareix / dbuf.conf
Last active August 29, 2015 14:13
DACP Client
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- Only root or user avahi can own the Avahi service -->
<policy user="avahi">
<allow own="org.freedesktop.Avahi"/>
</policy>
<policy user="root">