Skip to content

Instantly share code, notes, and snippets.

View kasuganosora's full-sized avatar
🙎‍♀️
Working at home

KasuganoSora kasuganosora

🙎‍♀️
Working at home
View GitHub Profile
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@miguelmota
miguelmota / request.go
Created July 9, 2020 23:15
Golang disable request chunked transfer encoding
// explicity setting the content-length will disable the "transfer-encoding: chunked" header
req.ContentLength = int64(len(requestBody))
// you can also remove the transfer-encoding header with this,
// however setting the content-length header is still required.
req.TransferEncoding = []string{"identity"}
@richlander
richlander / instructions.md
Last active March 24, 2024 14:54
Installing .NET Core 3.0 on Linux ARM64

Installing .NET Core on Linux ARM64

The following intructions can be used to install .NET Core on Linux ARM64.

Pro tip: Check out .NET Core Docker files to determine the exact instructions for installing .NET Core builds, for example .NET Core 3.1 ARM32 SDK Dockerfile.

Installing .NET Core Globally

The following instructions install the latest .NET Core globally. It isn't required to do that, but it provides the best experience.

@xpn
xpn / clr_via_native.c
Created April 11, 2018 21:34
A quick example showing loading CLR via native code
#include "stdafx.h"
int main()
{
ICLRMetaHost *metaHost = NULL;
IEnumUnknown *runtime = NULL;
ICLRRuntimeInfo *runtimeInfo = NULL;
ICLRRuntimeHost *runtimeHost = NULL;
IUnknown *enumRuntime = NULL;
LPWSTR frameworkName = NULL;
@stuartlangridge
stuartlangridge / icloud-cal.php
Created January 26, 2016 22:49
PHP to fetch a calendar from iCloud with authentication and CalDAV
<?php
// get this data by logging into icloud.com on the calendars page and looking at the dev tools
// as per https://translate.google.com/translate?sl=de&tl=en&js=y&prev=_t&hl=de&ie=UTF-8&u=http%3A%2F%2Fnico-beuermann.de%2Fblogging%2Farchives%2F115-Zugriff-auf-iCloud-Kalender-mit-Thunderbird.html&edit-text=&act=url
$account = array(
'server' => '', // note, this will be p12 or something, not P0; see the server that iclod.com serves json from
'icloudid' => '', // the "dsid"
'appleid' => '', // your Apple ID; will be an email address
'pass' => '', // password for your Apple ID
'calid' => '' // the "pGuid"
#block video ad
/ip firewall layer7-protocol
add name=youku-tudou regexp="^.+(v2html.atm.youku.com|atm.youku.com|ad.api.3g.tudou.com|ad.api.3g.youku.com).*\$"
add name=tencent regexp="^.+(fp.qq.com|rcgi.video.qq.com|tj.video.qq.com).*\$"
add name=iqiyi regexp="^.+(api.cupid.iqiyi.com).*\$"
add name=letv regexp="^.+(fz.letv.com|dc.letv.com|ark.letv.com).*\$"
add name=crossdomain regexp="^.+(crossdomain.xml).\$"
/ip firewall filter
add action=reject chain=forward comment="\CC\DA\D1\B6\CA\D3\C6\B5" layer7-protocol=tencent protocol=tcp reject-with=tcp-reset
@oblank
oblank / bleve_with_jieba.go
Last active May 14, 2024 15:57
bleve结合 jieba 分词实现中文分词
package main
import (
"fmt"
"github.com/blevesearch/bleve"
_ "github.com/wangbin/jiebago/analyse/tokenizers"
"log"
)
func main() {
@yulanggong
yulanggong / calender.md
Created June 13, 2014 05:35
日历标准格式研究

日历标准格式研究

日历的导入导出

格式

现在通用的日历格式是 iCalendar,通常扩展名是 .ics

BEGIN:VCALENDAR #日历开始

在这篇笔记的最前面,我一定要说,网络协议的设计者都是天才

使用SMTP发送邮件其实十分简单,就如同我们和人交谈别无二致。这里我们使用SMTP协议发送一封邮件,小小体会一下网络协议之美。我在这里使用Windows平台上的VS2013 作为编码环境,使用C++,和WinSock中的socket函数通信。

什么是SMTP,用Python中的SMTP模块发送一封邮件

SMTP--Simple Mail Transfer Protocol,简单邮件传输协议。这是一个应用层协议,我们可以使用此协议,发送简单的邮件。SMTP基于TCP协议,在不使用SSL,TLS加密的SMTP协议中,我们默认使用端口号25,在使用SSL\TLS的SMTP协议中,使用端口号465\587。

一次传输邮件的过程,其实就是一次和服务器对话的过程。为了标识这些对话中的各种动作,我们需要使用语言来和服务器沟通。例如客户端发送给服务器一条信息EHLO(Hello),服务器就知道这个客户端要给我发邮件了,这类似于我们人与人之间打招呼,我和服务器说:我要发邮件了!!!,于是服务器知道我要发邮件了,会给我回答一声:发吧。在SMTP协议中,也是同样,协议会返回一个标识码,来告诉我们服务器现在的状态,在我们打招呼之后,服务器一般会返回250,这告诉我们:“一切OK,放马过来吧”。

@kavu
kavu / example.go
Created September 28, 2013 10:01
Minimal Golang + Cocoa application using CGO. Build with `CC=clang go build`
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];