Skip to content

Instantly share code, notes, and snippets.

@simonliu009
simonliu009 / iTerm2 key bindings
Last active December 29, 2018 15:47
[iTerm2快捷键]iTerm2 快捷键及技巧 #iTerm2
^ 代表 shift
“cmd+d” 左右分屏
“^+cmd+d”实现上下分屏
“cmd+f” 搜索及文本复制,可以调出搜索框进行文本搜索,然后按下“tab”键会自动高亮当前文本后面的内容。最后按enter键将高亮文本复制到剪切板上。
“^+cmd+h” 调出复制过的文本历史
“cmd+alt+b” 按键回放
“^+cmd+o” 快速打开profile或者切换到指定tab
@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 / 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 / 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 / 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 / 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 / user_main.c
Last active January 7, 2019 13:59 — forked from 0x6e/user_main.c
ESP8266 Espressif RTC Example #ESP8266 #RTC
#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
os_timer_t rtc_test_t;
#define RTC_MAGIC 0x55aaaa55
typedef struct {
uint64 timeAcc;
uint32 magic;
@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
@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