Skip to content

Instantly share code, notes, and snippets.

@simonliu009
simonliu009 / yunfile_downloader
Last active January 7, 2019 13:59
Python: A python script #python #yunfile
#!/usr/bin/env python
# encoding: utf-8
"""
@version: 0.3
@author: endoffiht
@file: yunfile_downloader.py
@time: 15/6/29 18:06
"""
@simonliu009
simonliu009 / esp8266_pubsubclient.ino
Last active January 7, 2019 14:00 — forked from igrr/esp8266_pubsubclient.ino
Arduino:PubSubClient sample for ESP8266 Arduino #MQTT #Arduino
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
const char* ssid = ".................";
const char* password = "................";
char* topic = "esp8266_arduino_out";
char* server = "iot.eclipse.org";
@simonliu009
simonliu009 / hosts
Last active January 7, 2019 14:01 — forked from alswl/hosts
hosts for OpenWRT, for disable AD in xiaomi TV #hosts #xiaomiTV
127.0.0.1 api.ad.xiaomi.com
127.0.0.1 sdkconfig.ad.xiaomi.com
127.0.0.1 ad.mi.com
127.0.0.1 ad.xiaomi.com
127.0.0.1 ad1.xiaomi.com
127.0.0.1 adv.sec.miui.com
127.0.0.1 test.ad.xiaomi.com
127.0.0.1 new.api.ad.xiaomi.com
@simonliu009
simonliu009 / gist:86f863fcd775b6e78cd0c07ecd3cec8a
Last active January 7, 2019 14:01
debug: debug output macro, STM, debug宏定义,可以一次性开启或者关闭DEBUG信息 #STM #debug
#define __DEBUG__
#ifdef __DEBUG__
#define DEBUG(format,...) printf("File: "__FILE__", Line: %05d: "format"/n", __LINE__, ##__VA_ARGS__)
#else
#define DEBUG(format,...)
#endif
以上在STM32 System Workbench 编译通过,但是在Xcode 9.3 (Apple LLVM version 9.1.0 (clang-902.0.39.1))编译会提示错误:
Invalid suffix on literal; C++11 requires a space between literal and identifier
Fix insert" "
@simonliu009
simonliu009 / gist:128fd46155f66681a255d1000d767aec
Last active January 7, 2019 13:58
C++: Extracting individual digits from a float for LCD1602 number display, 从浮点数提取每一位的数字的函数实现,用于LCD1602显示,STM, Arduino,#c #LCD1602 #c++
#include "math.h"
int getDigits(float d, int digits)
{
int tempint = (int)(d / pow(10.0, digits - 1));
return (tempint % 10);
}
PM25Data[0] = (PM25data/10000)%10 + 0x30;
PM25Data[1] = (PM25data/1000)%10 + 0x30;
@simonliu009
simonliu009 / int_to_bin
Last active January 7, 2019 13:56
C: printf an integer to binary #c
/*
* @Author: Norton-Linux内核研究
* @Date: 2018-04-25 19:41:08
* @Last Modified by: simonliu
* @Last Modified time: 2018-04-25 19:41:27
* Source: https://blog.csdn.net/xzongyuan/article/details/29562371
*/
#include <stdio.h>
#include "string.h"
@simonliu009
simonliu009 / set single bit
Last active January 7, 2019 13:56
c: set bitx to 1 or 0 #c
//设置某位为1
number |= 1 << x; // 设置第x位为1
//清除某位
number &= ~(1 << x); // 置第x位为0
@simonliu009
simonliu009 / dec to bin 3
Last active January 7, 2019 13:56
c: int 十进制转二进制输出 dec to bin #c
/*
* @Author: simonliu
* @Date: 2018-04-25 21:48:58
* @Last Modified by: simonliu
* @Last Modified time: 2018-04-25 22:24:15
*/
#define __Mylog__
#ifdef __Mylog__
#define Mylog(format,...) printf("File: " __FILE__ ", Line: %05d: " format "/n", __LINE__, ##__VA_ARGS__)
#else
@simonliu009
simonliu009 / vistual studio code short cuts
Last active February 20, 2019 14:47
vsc: vistual studio code 快捷键 #vscode
多光标编辑 Multi cursor selection
基本: Alt+Click 即,按住 Alt 键,依次单击(或者选择)需要编辑的位置,可以依次添加光标。 Alt 键可以在设置中更改。
一列多光标: Shift+Alt+Down 或者 Shift+Alt+Up 可以在上下位置添加光标。
依次选中相同单词: 选中一个单词,按 Ctrl+D ,可以依次选中下一个相同单词。
选中所有相同单词: 选中一个单词,按 Shift+Ctrl+L (shift+cmd+L),可以一次性选中文本中 所有相同单词 。
矩形选择: 按住 Shift+Alt ,再进行选择,则选择区域是一个矩形。
括号选择: Shift+Alt+Right ,会选中匹配括号中的内容,并可以扩大选中区域。
选择相同实例:
@simonliu009
simonliu009 / Mac open bin
Last active January 7, 2019 14:00
Mac: open bin file 打开二进制文件 #macOS
1. Use sublime text to open this file
2. Use vi to open the file,then input the following command to switch to hex mode:
:%!xxd ——将当前文本转换为16进制格式。
:%!od ——将当前文本转换为16进制格式。
:%!xxd -c 12——将当前文本转换为16进制格式,并每行显示12个字节。
:%!xxd -r ——将当前文件转换回文本格式。
3. emacs
emacs filename