Skip to content

Instantly share code, notes, and snippets.

View aztack's full-sized avatar
🎯
Focusing

Wang Weihua aztack

🎯
Focusing
View GitHub Profile
on ShowTabWitePrefix(targetDomain) tell application "Google Chrome" set windowList to every window repeat with aWindow in windowList set tabList to every tab of aWindow set tabCount to count of tabList set currentTabIndex to 0 set targetTabs to {} -- Collect all the tabs matching the targetDomain prefix repeat with i from 1 to tabCount set aTab to item i of tabList considering case set tabURL to URL of aTab if tabURL starts with targetDomain then set end of targetTabs to {index:i, tab:aTab} end if end considering end repeat -- If there are any matching tabs, activate the next one in the list if (count of targetTabs) > 0 then set currentIndex to 0 repeat with i from 1 to count of targetTabs if active tab index of aWindow is (index of item i of targetTabs) then set currentIndex to i exit repeat end if end repeat -- if the current tab is the last matching one, activate the first one, else activate the next one
@aztack
aztack / equirectangular.py
Created April 14, 2023 01:48 — forked from jschoormans/equirectangular.py
generate 3D panorama views with stable diffusion
# %%
import replicate
model = replicate.models.get("prompthero/openjourney")
version = model.versions.get("9936c2001faa2194a261c01381f90e65261879985476014a0a37a334593a05eb")
PROMPT = "mdjrny-v4 style 360 degree equirectangular panorama photograph, Alps, giant mountains, meadows, rivers, rolling hills, trending on artstation, cinematic composition, beautiful lighting, hyper detailed, 8 k, photo, photography"
output = version.predict(prompt=PROMPT, width=1024, height=512)
# %%
# download the iamge from the url at output[0]
import requests
@aztack
aztack / index.html
Created November 10, 2021 11:35
Intercept file protocol in electron
<html>
<bod>
<iframe src="https://domain.com/page.html />
</body>
</html>
@aztack
aztack / SendSMS.java
Created January 22, 2012 02:30
send sms in android 2.2
public class SendSMS extends Activity {
private void setStatus(String text)
{
TextView status = (TextView)findViewById(R.id.status);
status.setText(text);
}
private void sendSMS(String phoneNumber, String message)
{
import { useRef, useState } from "react";
export interface InputMethodProps {
value: string;
onChange(value: string): void;
}
/**
* This hook handles composition events to prevent onChange
* from being called while the user is typing Chinese pinyin.
* And it will call onChange when the user finishes typing pinyin.
import https from 'https';
function fetch(hostname: string, search: string) {
const options = {
hostname,
port: 443,
path: search,
method: 'GET',
};
@aztack
aztack / captureSequences.ts
Created November 29, 2022 00:57
captureSequences
import JSZip from "jszip"; //https://github.com/Stuk/jszip
export function captureSequences(canvas: HTMLCanvasElement, filename: string, onCapture: (frame: number) => string) {
let frame = 0;
var zip = new JSZip();
const capture = () => {
const uri = canvas.toDataURL('png', 1);
var idx = uri.indexOf('base64,') + 'base64,'.length;
var content = uri.substring(idx);
const frameName = onCapture(frame++);
@aztack
aztack / recordCanvasStream.ts
Created November 18, 2022 06:38
recordCanvasStream
**
* Record canvas stream into a webm file
* @param canvas HTMLCanvasElement
* @param options {duration: number, fps: number}
* @returns Promise<Blob> | ((discard:boolean) => Promise<Blob|null>)
* @example
* // Stop after 5 seconds
* const blob = await recordCanvasStream(canvas, { duration: 5, fps: 30 });
* downloadBlob(blob, 'recording.webm');
*
@aztack
aztack / init.gradle
Created April 2, 2020 09:52
init.gradle
// ~/.gradle/init.gradle
allprojects {
def google_uri = new URI('https://maven.aliyun.com/repository/google')
def central_uri = new URI('https://maven.aliyun.com/repository/central')
def jcenter_uri = new URI('https://maven.aliyun.com/repository/jcenter')
repositories {
all {
ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
@aztack
aztack / cryptography-file-formats.md
Created October 12, 2022 14:37 — forked from tuansoibk/cryptography-file-formats.md
Cryptography material conversion and verification commands
  1. Introduction
  2. Standards
  3. Common combinations
  4. Conversion
  5. Verification/Inspection
  6. Tips for recognising

Introduction

It happens that there are many standards for storing cryptography materials (key, certificate, ...) and it isn't always obvious to know which standard is used by just looking at file name extension or file content. There are bunch of questions on stackoverflow asking about how to convert from PEM to PKCS#8 or PKCS#12, while many tried to answer the questions, those answers may not help because the correct answer depends on the content inside the PEM file. That is, a PEM file can contain many different things, such as an X509 certificate, a PKCS#1 or PKCS#8 private key. The worst-case scenario is that someone just store a non-PEM content in "something.pem" file.