Skip to content

Instantly share code, notes, and snippets.

View ladyrick's full-sized avatar
🎯
Focusing

LadyRick ladyrick

🎯
Focusing
View GitHub Profile
@ladyrick
ladyrick / GetQueryString.js
Last active April 6, 2017 05:58
用JS获取地址栏参数的方法
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!==null) {
return unescape(r[2]);
} else {
return null;
}
}
@ladyrick
ladyrick / noScrollBar.html
Created May 19, 2017 07:46
html 不显示滚动条,但是可以向下滚动
<body style="margin:0;">
<div style="overflow:hidden;">
<div id="box" style="width:110%;height:100%;overflow-x:hidden;overflow-y:auto;">
</div>
</div>
<script>
box = document.getElementById("box");
for (var r of ['0', 'f'])
for (var g of ['0', 'f'])
for (var b of ['0', 'f']) {
@ladyrick
ladyrick / cast2bits.cpp
Last active July 28, 2019 08:18
Given a variable or an object, then print the memory state. The MSB is on the left and the LSB is on the right.
#include <iostream>
#include <string>
#include <sstream>
#include <bitset>
#include <typeinfo>
using namespace std;
class cast2bits {
private:
@ladyrick
ladyrick / .bashrc
Last active August 4, 2018 16:37
my .bashrc
export PS1='\[\033[35;1m\]\w\[\033[36;1m\] > \[\033[00m\]'
alias ls="ls --color=auto"
alias ll="ls -alhF"
alias la="ls -a"
alias l="ll"
alias ..="cd .."
@ladyrick
ladyrick / NumberOf1Between1andN
Last active August 11, 2018 07:54
求1到n的数字中,1的个数
int NumberOf1Between1AndN_Solution(int n)
{
int ones = 0;
for (long long m = 1; m <= n; m *= 10)
ones += (n / m + 8) / 10 * m + (n / m % 10 == 1) * (n % m + 1);
return ones;
}
@ladyrick
ladyrick / str_split.cpp
Created August 12, 2018 08:11
c++ string split()
vector<string> split(const string &str, const string &c) {
int start = 0;
int npos = str.find(c, start);
vector<string> result;
while (start < str.length() && npos != str.npos) {
result.push_back(str.substr(start, npos - start));
start = npos + c.length();
npos = str.find(c, start);
}
result.push_back(str.substr(start, str.length() - start));
@ladyrick
ladyrick / print_vtable.cpp
Created August 28, 2018 03:35
print the virtual function table of an object.
#include <cstring>
#include <iomanip>
#include <iostream>
using namespace std;
class Base1 {
public:
virtual void f() { cout << "Base1::f" << endl; }
virtual void g() { cout << "Base1::g" << endl; }
virtual void h() { cout << "Base1::h" << endl; }
@ladyrick
ladyrick / pymsgbox
Last active November 22, 2018 02:40
python的message box
class PyMsgBox():
def __init__(self):
from tkinter import Tk, messagebox
self.msgbox = messagebox
self.root = Tk()
self.root.wm_attributes('-topmost', 1)
self.root.withdraw()
def info(self, msg):
self.msgbox.showinfo("来自ladyrick的提示", msg)
[user]
name = ladyrick
email = ladyrick@qq.com
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
[gui]
encoding = utf-8
[i18n]
commitencoding = utf-8
logoutputencoding = utf-8
from google.protobuf import text_format
def ParseFromBinary(bytestr, message):
message.ParseFromString(bytestr)
def ParseFromText(string, message):
text_format.Merge(string, message)
def SerializeToBinary(message):
return message.SerializeToString()