Skip to content

Instantly share code, notes, and snippets.

@wang-nima
wang-nima / gist:edac2faf8e6ea388d911344c44364fd8
Created Sep 18, 2017 — forked from ept/gist:4475995
Syntax highlighting code for PowerPoint (Mac OS)
View gist:edac2faf8e6ea388d911344c44364fd8

How to add syntax-highlighted code to PowerPoint slides (Mac OS)

  1. pygmentize -f rtf FILE | pbcopy
  2. Paste into TextEdit (in rich text mode: Format → Make Rich Text before pasting), and copy to clipboard again.
  3. In PowerPoint, Edit → Paste Special… → Styled Text.

(Pasting RTF directly into PowerPoint doesn't work correctly, at least with PowerPoint 2008 — it extends colour spans longer than it should, and sometimes removes line breaks. Going via TextEdit seems to solve the problem.)

@wang-nima
wang-nima / .cpp
Created Oct 25, 2015
像素比例
View .cpp
struct TreeNode {
bool color;
vector<TreeNode*> next;
TreeNode (bool c) : color(c), next(4, nullptr) {}
};
double getPercentage(TreeNode *root) {
if (next[0] == nullptr && next[1] == nullptr && next[2] == nullptr && next[3] == nullptr) {
return 1;
}
View .cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int partition(vector<int> &v, int low, int high) {
int pivot = v[low];
int index = low + 1;
for (int i = low + 1; i <= high; i++) {
if (v[i] < pivot) {
@wang-nima
wang-nima / .cpp
Created Sep 22, 2015
1. 给一个二维数组,对角线打印 例子: 1 2 3 4.5 6 7 8 9 10 11 12 打印出 1 2 5 3 6 9 4 7 10 8 11 12
View .cpp
// http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=141288&extra=page%3D1%26filter%3Dsortid%26sortid%3D311%26sortid%3D311
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
using namespace std;
void print(vector<vector<int>> a) {
int m = (int)a.size();
@wang-nima
wang-nima / client.go
Last active Sep 17, 2015 — forked from jordanorelli/client.go
rpc server example in go
View client.go
package main
import (
"bufio"
"log"
"net/rpc"
"os"
)
func main() {
View union find set .cpp
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
#include <unordered_map>
using namespace std;
vector<int> father;
void init() {
@wang-nima
wang-nima / a.cpp
Created Sep 11, 2015
decode string
View a.cpp
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
using namespace std;
string intToBytes(unsigned int a) {
unsigned char mask = 0xff;
string ret;
You can’t perform that action at this time.