Skip to content

Instantly share code, notes, and snippets.

View longyue0521's full-sized avatar

Longyue Li longyue0521

  • ELEX Technology
  • Beijing, China
  • 23:51 (UTC +08:00)
View GitHub Profile
@longyue0521
longyue0521 / gomock.md
Created January 19, 2023 10:38 — forked from thiagozs/gomock.md
Tutorial gomock

08/16/17 by  Sergey Grebenshchikov

No Comments

This is a quick tutorial on how to test code using the GoMock mocking library and the standard library testing package testing.

GoMock is a mock framework for Go. It enjoys a somewhat official status as part of the github.com/golang organization, integrates well with the built-in testing package, and provides a flexible expectation API.

@longyue0521
longyue0521 / pre-commit
Created September 1, 2022 02:09 — forked from liues1992/pre-commit
golang basic pre-commit check, including gofmt goimports golint
#!/bin/sh
# Partly copy from https://tip.golang.org/misc/git/pre-commit
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# git gofmt pre-commit hook
#
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
@longyue0521
longyue0521 / pre-commit
Created September 1, 2022 02:09 — forked from liues1992/pre-commit
golang basic pre-commit check, including gofmt goimports golint
#!/bin/sh
# Partly copy from https://tip.golang.org/misc/git/pre-commit
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# git gofmt pre-commit hook
#
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
@longyue0521
longyue0521 / fast_reading_input.c
Created May 16, 2018 11:24
Reading input in C
/* https://bugdivine.blogspot.com/p/fast-input-reader-in-cc.html */
#include <stdio.h>
int fastRead_int() {
register int c = getchar_unlocked();
int x;
x = 0;
int neg = 0;
for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());
if(c=='-') {
@longyue0521
longyue0521 / fast_read_int.c
Last active May 16, 2018 10:50
Fast Read int From Stdin In C
int read_int() {
char c = getchar_unlocked();
while(c<'0' || c>'9') c = getchar_unlocked();
int ret = 0;
while(c>='0' && c<='9') {
ret = 10 * ret + c - 48;
c = getchar_unlocked();
}
return ret;
}
@longyue0521
longyue0521 / reset_password.md
Created May 11, 2018 12:34
Virtualbox中Ubuntu忘记密码解决办法
@longyue0521
longyue0521 / memory_layout.md
Created December 22, 2017 08:39 — forked from CMCDragonkai/memory_layout.md
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@longyue0521
longyue0521 / byobuCommands
Created December 14, 2017 08:51 — forked from jshaw/byobuCommands
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@longyue0521
longyue0521 / clear_stdin_buff.c
Created September 14, 2017 09:36
clear standard input buffer
#include <stdio.h>
void clear_stdin_buffer() {
char ch;
while( (ch = getchar()) != '\n' && ch != EOF );
}
@longyue0521
longyue0521 / str_len_arr.c
Created September 14, 2017 08:00
strlen() implementation in c
#include <stddef.h>
/**
* return length of valid string which has '\0' or 0 as terminated
*/
size_t
str_len( const char *str)
{
size_t i;
for( i = 0; str[i] != '\0'; i++);
return i;