Skip to content

Instantly share code, notes, and snippets.

View re-imagined's full-sized avatar
🎯
Focusing

candy re-imagined

🎯
Focusing
View GitHub Profile
@re-imagined
re-imagined / emojis.json
Created December 18, 2017 05:47 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family_mothers_two_girls", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👧", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family_mothers_children", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👦", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family_mothers_two_boys", "shortname": "", "unicode": "", "html": "👩‍👩‍👦‍👦", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family_two_girls", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👧", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👦", "name": "family_children", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👦", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👦‍👦", "name": "family_two_biys", "shortname": "", "unicode": "", "html": "👨&zw
@re-imagined
re-imagined / beautiful_idiomatic_python.md
Created October 10, 2016 09:32 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@re-imagined
re-imagined / python2中汉字乱码问题.md
Last active June 30, 2016 08:02
python2中汉字乱码问题

#python2中汉字乱码问题

###1、写的代码模块需要指定编码 如果代码没有指定coding,python就默认所有的字符为ASCII码, ASCII码只支持256个字符,ASCII码不支持中文,所以就报错。 所以要在代码前写上#coding:utf-8或#coding:gbk 但通用写上#coding:utf-8

###2、python2内部所有编码统一为unicode unicode可以处理世界上所有语言的字符。

@re-imagined
re-imagined / decorator_cache.py
Last active May 24, 2016 03:53 — forked from selfboot/decorator_cache.py
用装饰器实现缓存机制,避免斐波那契数列递归实现中的重复调用,然后比较存在缓存和没有缓存下的运行时间。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from functools import wraps
def fib_direct(n):
assert n > 0, 'invalid n'
if n < 3:
return n
else:
@re-imagined
re-imagined / tree.md
Created April 24, 2016 14:34 — forked from upsuper/tree.md
一行 Python 实现树

一行 Python 实现树

使用 Python 内置的 defaultdict,我们可以很容易的定义一个树形数据结构:

def tree(): return defaultdict(tree)

就是这样!

将两计算机通过双绞线直接连接就是一端是586A,一端是586B。

  • 568A标准:绿白,绿,橙白,蓝,蓝白,橙,棕白,棕
  • 568B标准:橙白,橙,绿白,蓝,蓝白,绿,棕白,棕
  • 568A和568B的标准就是把 1 和3,2 和6 的顺序换过来了,其他不变。
两台电脑直联,一头接568A,一头接568B,8根线中4,5,7,8不用,只有橙白1,橙2,绿白3,绿6四根线传数据。
1,2发数据,3,6接收数据,所以必须1,3相接,2,6相接,才能实现一头发数据,一头接收数据。
@re-imagined
re-imagined / 机器的位数与数据类型的关系.md
Last active April 5, 2016 05:00
机器的位数与数据类型的关系

32位编译器:

  • 32位系统下指针占用4字节
      char1个字节
      char*即指针变量): 4个字节32位的寻址空间是2^32, 即32个bit也就是4个字节同理64位编译器)
      short int : 2个字节
      int4个字节
      unsigned int : 4个字节
 float: 4个字节
@re-imagined
re-imagined / GrayCode.md
Last active April 5, 2016 05:01
GrayCode_Generator

这里使用两种方法来生成格雷码

######第一种是生成二进制的字符串

vector<string> GrayCode(int n)
{
    int x = pow(2, n);//n位格雷码有 x = 2^n 个
    vector<string> graycode;//用字符串来存格雷码

    if(n == 0)
@re-imagined
re-imagined / 以各种进制输出数字.md
Last active April 5, 2016 05:03
以各种进制输出数字(两种方法)
#include <iostream>
#include <bitset>
#include <stdlib.h>
using namespace std;
int main()  
{
  int a = 100;  
  cout<<"十进制    "<<a<<endl;  
 cout&lt;&lt;"十六进制 "&lt;
@re-imagined
re-imagined / char STR[] = "Hello\!".md
Last active April 5, 2016 05:06
用char 来声明字符串时,最后会接一个结束符,长度比字符数大一
char STR[] = "Hello\!";

有六个字符,但

cout << sizeof(STR); 

的结果是7,因为后面还有一个结束符 "\0"。

for(int i = 0 ; i&lt;=6; i++){