Skip to content

Instantly share code, notes, and snippets.

View xfstart07's full-sized avatar
🎯
Focusing

LeonXu xfstart07

🎯
Focusing
View GitHub Profile
@xfstart07
xfstart07 / wait_go.go
Last active May 5, 2023 09:37
waitgroup control #go
package concurr
import "sync"
type routineGroup struct {
waitGroup sync.WaitGroup
}
func newRoutineGroup() *routineGroup {
return new(routineGroup)
@xfstart07
xfstart07 / struct_implement_interface.go
Created November 14, 2022 09:55
Go 约束 struct 实现某个接口
// Metric interface
type Metric interface {
}
var _ Metric = (*metric)(nil)
type metric struct {
}
@xfstart07
xfstart07 / compareversion.go
Last active November 10, 2022 02:27
compare version
// CompareVersion 比较字符串版本号
// a == b: true, a > b: true, a < b: false
func CompareVersion(a, b string) bool {
if a == b {
return true
}
newv := strings.Split(a, ".")
curv := strings.Split(b, ".")
@xfstart07
xfstart07 / active_object.go
Created April 1, 2022 10:27
active object
package main
import "fmt"
type One int
type Ten int
type work struct {
object interface{}
result chan error
@xfstart07
xfstart07 / goinstall.sh
Last active February 9, 2022 09:07
go install
cd ~
wget https://dl.google.com/go/go1.16.13.linux-amd64.tar.gz
tar -C /usr/local -zxvf go1.16.13.linux-amd64.tar.gz
echo "export GOROOT=/usr/local/go" > /etc/profile
echo "PATH=$PATH:$GOROOT/bin" > /etc/profile
source /etc/profile
@xfstart07
xfstart07 / runtime-slice.go
Created December 26, 2018 03:02
slice grow
func growslice(et *_type, old slice, cap int) slice {
if raceenabled {
callerpc := getcallerpc()
racereadrangepc(old.array, uintptr(old.len*int(et.size)), callerpc, funcPC(growslice))
}
if msanenabled {
msanread(old.array, uintptr(old.len*int(et.size)))
}
if et.size == 0 {
@xfstart07
xfstart07 / ImageCompress.java
Created August 11, 2015 09:49
图片压缩帮助方法
package com.yibu.kuaibu.utils;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
/**
@xfstart07
xfstart07 / gmaps.js
Last active August 29, 2015 14:18
jquery autocomplete 和 google maps 配合做 地区搜索
/**
* Created by xufei on 4/8/15.
*/
var service;
var map;
function update_ui( address ) {
$('#input').autocomplete("close");
$('#input').val(address);
@xfstart07
xfstart07 / search_box_gmaps.js
Created April 9, 2015 10:10
谷歌地图 关键字地区搜索
/**
* Created by xufei on 4/9/15.
*/
function search_box_gmaps() {
var input = $('.pac-input').each(function(index, element) {
var searchBox = new google.maps.places.SearchBox(element);
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
@xfstart07
xfstart07 / transaction.rb
Created March 9, 2015 10:36
Rails transaction
begin
Post.transaction do
# 删除旧数据
Post.delete_all
# 例子 新数据
datas [{:title => "title1", :slug => "title-1"},{:title => "Title 2", :slug => "Title 2"}]
counter = 0
datas.each do |d|
post = Post.new(d)