Skip to content

Instantly share code, notes, and snippets.

@Wonicon
Wonicon / rvm-note.md
Last active August 29, 2015 14:16
RVM使用笔记

参考来源:

  1. Ruby-china

  2. Stackoverflow

列出可获得的所有Ruby版本(列表较长,速度较慢):

$ rvm list known
@Wonicon
Wonicon / ros-note-data.md
Last active August 29, 2015 14:16
ROS笔记

##创建msg

###msg是什么

msg是一个普通的文本文件,描述了一个消息的数据成员(数据结构),它将作为原型去生成各种编程语言能够使用的数据类型。

###Creating a msg

Firstly, we need a msg folder with a filename.msg file under the package folder.

@Wonicon
Wonicon / algo.rb
Last active August 29, 2015 14:16
Misc of Ruby
#!/usr/bin/env ruby
print "input n: "
n = gets.chomp.to_i
r = 0
(1..(n - 1)).each do |i|
((i + 1)..(n)).each do |j|
(1..j).each {r += 1}
end
@Wonicon
Wonicon / kb.c
Last active September 27, 2015 07:29
Detect CAPSLOCK
// I find the excellent code at http://stackoverflow.com/a/20946151
// Put it here for further work on the CAPSLOCK detection prog
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
#include <string.h>
#include <stdio.h>
@Wonicon
Wonicon / expr.y
Created October 13, 2015 11:26
expr parser
%token plus minus mul div lp rp num float
%nonassoc num float
%left plus minus
%left mul div
%right lp rp
%%
exp : exp plus exp
| exp minus exp
@Wonicon
Wonicon / vivado.fish
Created October 27, 2015 09:08
To be compatible with fish shell
# Set Vivado environment path
set --export XILINX_VIVADO /opt/Xilinx/Vivado/2015.2
set --export LD_LIBRARY_PATH $LD_LIBRARY_PATH /opt/Xilinx/Vivado/2015.2/lib/lnx64.o
set --export PATH $PATH /opt/Xilinx/Vivado/2015.2/bin
@Wonicon
Wonicon / cache.md
Last active November 4, 2015 04:39
pipline笔记

一种cache的外围结构, 不涉及缓存策略和替换算法:

  1. cache 有自己的时钟, 保证完成检测, 替换以及从内存读取一份数据块的时间
  2. miss 信号异步驱动 cpu 停止流水线
  3. 时钟到来一定让 miss 信号无效
  4. 组合逻辑扫描 cache, miss 则 miss 信号有效

可行性方面存在问题: 由于时钟不一致, cpu 访问 cache 发现 miss 时可能已经没有足够的时间进行内存读写.

Update: 可以增加计时器, miss 信号相当于该计时器的异步 reset, 计时器结束时同步地写入 valid bit 并且恢复 cpu

@Wonicon
Wonicon / funny.c
Created November 4, 2015 08:03
funny c
void foo()
{
if (1) {
1;
} else if (2) {
2;
} else while (3) {
3;
} else for (;;) {
4;
@Wonicon
Wonicon / rename.cs
Last active January 6, 2016 18:47
PA check scripts
namespace RenameFiles
{
class Program
{
static void Main(string[] args)
{
string paZipPath = @"C:\";
var fileNameList = Directory.GetFiles(paZipPath);
foreach (var filename in fileNameList)
{
@Wonicon
Wonicon / pwm.v
Created December 15, 2015 14:27
Nexys PWM Audio tryout
`timescale 1ns / 1ps
// Origin: http://www.fpga4fun.com/MusicBox2.html
module pwm(
input CLK100MHZ,
input BTNC,
output AUD_PWM,
output AUD_SD
);
parameter clk_divider_440 = (100000000 / 440) / 2;