Skip to content

Instantly share code, notes, and snippets.

function getPageTotal(offset = 0) {
req = new XMLHttpRequest();
req.open(
'GET',
`https://shopee.vn/api/v4/order/get_all_order_and_checkout_list?limit=20&offset=${offset}`,
false
);
req.send();
a = JSON.parse(req.responseText);
if (a.data.next_offset === -1) return 0;
@katagaki
katagaki / EncodedPolylines.swift
Created April 22, 2023 09:12
Swift implementation of the Encoded Polyline Algorithm Format by Google.
// Encoded polyline algorithm from https://developers.google.com/maps/documentation/utilities/polylinealgorithm
func encode(_ original: Double) -> String {
var point = UInt32(abs(Int((original * 100000).rounded())))
if original < 0 {
point = ~point + 1
}
point <<= 1
if original < 0 {
point = ~point
}
@vukcevich
vukcevich / endian-conversion-cheat-sheet.swift
Created December 21, 2016 21:33 — forked from DevAndArtist/endian-conversion-cheat-sheet.swift
A cheat sheet for byte conversion of number types in Swift 3.0
func _convertToBytes<T>(_ value: T, withCapacity capacity: Int) -> [UInt8] {
var mutableValue = value
return withUnsafePointer(to: &mutableValue) {
return $0.withMemoryRebound(to: UInt8.self, capacity: capacity) {
return Array(UnsafeBufferPointer(start: $0, count: capacity))
}
}
@kelvie
kelvie / 0001-Add-a-lockdown_hibernate-parameter.patch
Created October 2, 2022 23:39
Enable hibernate during lockdown
From e4db4f07e77feb1c126e7afbf441e9eae34b4e57 Mon Sep 17 00:00:00 2001
From: Kelvie Wong <kelvie@kelvie.ca>
Date: Sun, 2 Oct 2022 13:23:25 -0700
Subject: [PATCH] Add a lockdown_hibernate parameter
This allows the user to tell the kernel that they know better (namely,
they secured their swap properly), and that it can enable hibernation.
Signed-off-by: Kelvie Wong <kelvie@kelvie.ca>
---
@Sh4yy
Sh4yy / clx.go
Created April 25, 2024 20:39
Generate CLI commands for common tasks.
package main
import (
"context"
"errors"
"fmt"
"io"
"log"
"os"
"runtime"
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active April 26, 2024 02:03
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@virtualstaticvoid
virtualstaticvoid / iptables_rules.sh
Created June 14, 2011 08:58
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@imba-tjd
imba-tjd / .Cloud.md
Last active April 26, 2024 01:58
☁️ 一些免费的云资源

IaaS指提供系统(可以自己选)或者储存空间之类的硬件,软件要自己手动装;PaaS提供语言环境和框架(可以自己选);SaaS只能使用开发好的软件(卖软件本身);BaaS一般类似于非关系数据库,但各家不通用,有时还有一些其它东西。

其他人的集合

@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active April 26, 2024 01:57
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@mikhailov-work
mikhailov-work / turbo_colormap.py
Created August 8, 2019 23:31
Turbo Colormap Look-up Table
# Copyright 2019 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# Author: Anton Mikhailov
turbo_colormap_data = [[0.18995,0.07176,0.23217],[0.19483,0.08339,0.26149],[0.19956,0.09498,0.29024],[0.20415,0.10652,0.31844],[0.20860,0.11802,0.34607],[0.21291,0.12947,0.37314],[0.21708,0.14087,0.39964],[0.22111,0.15223,0.42558],[0.22500,0.16354,0.45096],[0.22875,0.17481,0.47578],[0.23236,0.18603,0.50004],[0.23582,0.19720,0.52373],[0.23915,0.20833,0.54686],[0.24234,0.21941,0.56942],[0.24539,0.23044,0.59142],[0.24830,0.24143,0.61286],[0.25107,0.25237,0.63374],[0.25369,0.26327,0.65406],[0.25618,0.27412,0.67381],[0.25853,0.28492,0.69300],[0.26074,0.29568,0.71162],[0.26280,0.30639,0.72968],[0.26473,0.31706,0.74718],[0.26652,0.32768,0.76412],[0.26816,0.33825,0.78050],[0.26967,0.34878,0.79631],[0.27103,0.35926,0.81156],[0.27226,0.36970,0.82624],[0.27334,0.38008,0.84037],[0.27429,0.39043,0.85393],[0.27509,0.40072,0.86692],[0.27576,0.41097,0.87936],[0.27628,0.42118,0.89123],[0.27667,0.43134,0.90254],[0.27691,0.44145,0.913