Skip to content

Instantly share code, notes, and snippets.

View ynyyn's full-sized avatar
☹️
Idling away time... - I may be slow to respond.

一年又一年 ynyyn

☹️
Idling away time... - I may be slow to respond.
  • *Cross-stack Developer who likes doing non-professional research; and a Lifelong(maybe?) Enthusiastic Learner (or "Student" instead, I wish), with this fictional profile in cyberspace.
  • 地球 · 中国 / China, Earth
  • 06:28 (UTC +08:00)
View GitHub Profile
@ynyyn
ynyyn / NSStringEncodeURIComponent.m
Last active April 11, 2025 10:45
A Simulate implementation of `encodeURIComponent()` in Cocoa Objective-C that provides similar percent-encoding behaviour.
/// Simulate implementation of `encodeURIComponent()` in Cocoa Objective-C that provides similar
/// percent-encoding behaviour.
///
/// Escapes all characters except: `A–Z a–z 0–9 - _ . ! ~ * ' ( )`
+ (NSString *)encodeURIComponent:(NSString *)string {
NSMutableCharacterSet *uriComponentAllowedCharacterSet;
// Based on `URLQueryAllowedCharacterSet`, while it contains extra characters that need to be
// escaped as for `encodeURIComponent()`.
uriComponentAllowedCharacterSet = [NSCharacterSet.URLQueryAllowedCharacterSet mutableCopy];
@ynyyn
ynyyn / 坦白说皮一皮源代码((.js
Created April 3, 2018 05:17
QQ坦白说,登录态下,自动带 Token 跳转脚本
(function () {
function CSRFToken(str) {
var hash = 5381;
for (var i = 0, len = str.length; i < len; ++i)
hash += (hash << 5) + str.charAt(i).charCodeAt();
return hash & 2147483647
}
function getCookie(c, name) {