Skip to content

Instantly share code, notes, and snippets.

View dkwingsmt's full-sized avatar

Tong Mu dkwingsmt

View GitHub Profile
@dkwingsmt
dkwingsmt / f-d-r.md
Last active December 20, 2015 08:59

System Info:

  1. uname -a:

    Linux dkwings-linux 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 i686 i686 i386 GNU/Linux
    
  2. lsb_release -a:

    No LSB modules are available.
    Distributor ID:	Ubuntu
    

Description: Ubuntu 12.04.2 LTS

%% Matlab
N=4;
Obs = [2,3;3,2;3,3;3,4];
Probabilities = [0.1, 0.2, 0.3, 0.4];
Map = ones(N, N);
Map((Obs-1)*[N;1]+1) = 0; % ([col_id, row_id]-1)*[N, 1] + 1 => mat_id
Map(Map==1) = 1 : (N*N - size(Obs, 1)); % Need transposition
A = zeros(N*N, N*N);
@dkwingsmt
dkwingsmt / toggle_mute
Last active December 20, 2015 14:49
Toggle mute/unmute.
#!/bin/bash
# Tested on Ubuntu 12.04 and PulseAudio.
# Since Unity or Gnome has direct support for volume control, you won't need this unless you use other windows manager, e.g. i3.
# Try `pactl list` to see the list of sinks you own, or try `toggle_mute 0` `toggle_mute 1` one by one.
if [ "$#" = "1" ]
then
FORMAT='$0~"Sink"{start=0} $0~"Sink #'"$1"'"{start=1} $1~"Mute"&&start {print $2~"no"}'
// Input:
// average combo,
// overall turns,
// OVERALL rarity,
// amount of floors of this dungeon
// amount of pets in the party
// Return:
// [score_combo, score_turns, score_rarity]
// Note that score_rarity is unprecise when the party is not full (6 pets)
// Reference of algorithm and data:
#include <iostream>
#include <vector>
#include <list>
using namespace std;
struct record {
record(int _h): h(_h) { }
size_t x;
int h;
@dkwingsmt
dkwingsmt / tmp.cpp
Last active September 8, 2015 08:43
/*
* I've corrected it myself. See comment. Thank you!
*/
#include <thread>
#include <fstream>
#include <list>
using namespace std;
@dkwingsmt
dkwingsmt / Basic calculator III.cpp
Last active October 23, 2015 18:23
Basic calculator III
#include <iostream>
#include <sstream>
using namespace std;
class Solution {
public:
struct OpProperty {
int oplv;
import requests
from bs4 import BeautifulSoup
import re
from collections import defaultdict
def is_quest_table(t):
g=t.findNext('th')
return g and g.text.upper() == 'ID'
# Parses a table into list of lists, especially parses colspan and rowspan
# After
编组任意舰船2只
编组驱逐4只
编组轻巡旗舰+驱逐3只
编组任意舰船6只
编组轻巡2只
编组任意舰船1只,限第2舰队
编组重巡2只
编组天龙+龙田
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char *str;
int beg;
int end;
} Segment;
void parse(Segment *pre, Segment *mid) {