Skip to content

Instantly share code, notes, and snippets.

View gsw945's full-sized avatar
🙏
buddha-like coding

玖亖伍 gsw945

🙏
buddha-like coding
View GitHub Profile
@gsw945
gsw945 / gist:47aa138cd0184124ef3b2b713294444a
Created July 16, 2021 08:26 — forked from getify/gist:7325764
converting between Uint8Arrays and binary-encoded strings and word-arrays (for crypto purposes, with CryptoJS and NaCL)
/*
wordArray: { words: [..], sigBytes: words.length * 4 }
*/
// assumes wordArray is Big-Endian (because it comes from CryptoJS which is all BE)
// From: https://gist.github.com/creationix/07856504cf4d5cede5f9#file-encode-js
function convertWordArrayToUint8Array(wordArray) {
var len = wordArray.words.length,
u8_array = new Uint8Array(len << 2),
offset = 0, word, i
@gsw945
gsw945 / demo-01.py
Created November 7, 2020 14:22
python subprocess realtime output
# from: https://www.stefaanlippens.net/python-asynchronous-subprocess-pipe-reading/
import sys
from subprocess import Popen, PIPE
import random
import time
from threading import Thread
from queue import Queue
class ClassName(object):
"""docstring for ClassName"""
@gsw945
gsw945 / .vimrc
Last active August 6, 2022 07:52
`~/.vimrc`
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" Highlight current line
set cursorline
" display line number
/* 鼠标特效 */
var a_idx = 0;
jQuery(document).ready(function($) {
$("body").click(function(e) {
var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善");
var $i = $("<span />").text(a[a_idx]);
a_idx = (a_idx + 1) % a.length;
var x = e.pageX,
y = e.pageY;
$i.css({
@gsw945
gsw945 / optimizations.md
Created April 8, 2020 07:02 — forked from mandarinx/optimizations.md
Unity3D optimization tips

Unity3D optimization tips

Some code allocates memory when running in the editor and not on the device. This is due to Unity doing some extra error handling so possible error messages can be output in the console. Much of this code is stripped during build. It's therefore important to profile on device, and do it regularly.

Optimizations often makes code more rigid and harder to reason. Don't do it until you really need to.

When profiling, wrap methods or portions of a method in Profiler.BeginSample(string name) and Profiler.EndSample() to make them easier to find in the profiler.

public class SomeClass {
@gsw945
gsw945 / ffmpeg.md
Created December 5, 2019 05:11 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@gsw945
gsw945 / client.js
Created October 16, 2019 03:30 — forked from hagino3000/client.js
WebSocket with binary data
var socket = null;
function bootstrap() {
// 適当な図形を描画
var c = document.getElementById('mycanvas');
var ctx = c.getContext('2d');
ctx.globalalpha = 0.3;
for(var i=0; i<1000; i++) {
ctx.beginPath();
@gsw945
gsw945 / MirrorMigrationTool.cs
Created July 19, 2019 06:06 — forked from SoftwareGuy/MirrorMigrationTool.cs
Converts old UNET code into modern Mirror Networking code
// Mirror Network Migration Tool
// Written by M. Coburn (@coburn64 on Twitter/SoftwareGuy on Github)
// This file is part of Mirror Networking by Coburn64, Lymdun, vis2k and Paul (goldbug).
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
@gsw945
gsw945 / biqugeso_crawl.py
Last active May 29, 2019 05:50
笔趣阁-《弃少归来张恒》 爬虫
# -*- coding: utf-8 -*-
import re
import json
import scrapy
from scrapy.crawler import CrawlerProcess
class BiqugesoSpider(scrapy.Spider):
# custom_settings = {}
@gsw945
gsw945 / scheduler-client-demo.py
Created April 2, 2019 04:18
apscheduler rpyc server and client demos
from time import sleep
import rpyc
conn = rpyc.connect('localhost', 12345)
job = conn.root.api_test_job(args=['Hello, World'])
sleep(2)
conn.root.remove_job(job.id)