Skip to content

Instantly share code, notes, and snippets.

View huruji's full-sized avatar
☂️
被社会毒打的频率奇高

huruji huruji

☂️
被社会毒打的频率奇高
View GitHub Profile
@huruji
huruji / README.md
Created September 22, 2024 09:20 — forked from veltman/README.md
Gif rendering - SVG to GIF

Testing in-browser gif generation from an SVG with gif.js. Works in recent Chrome/Safari/Firefox.

Process:

  1. Create a standard SVG line chart.
  2. Step through in-between frames of the line chart: for each one, update the SVG, render to an image, add the image element to a stack of gif frames.
  3. Render frames together in the background using gif.js web workers.
  4. When rendering's complete, add the blob URL as an image and start the SVG on an infinite loop with d3.timer (gratuitous).

See also: Gif Globe, Gif New Jersey

@huruji
huruji / gist:2d26f4d18436e43fbd8092fe5b0e2a49
Last active December 20, 2021 06:34 — forked from hyg/gist:9c4afcd91fe24316cbf0
在golang中打开浏览器
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@huruji
huruji / ex1
Created October 6, 2021 19:13 — forked from Quby/ex1
libuv example, timers and mkdir
#include "./../deps/libuv/include/uv.h"
#include <stdio.h>
int msg;
void mkdir_cb (uv_fs_t* req) {
int* msg = req->data;
printf("send(%d)\n", *msg);
}
@huruji
huruji / binding.gyp
Created October 6, 2021 18:01 — forked from bellbind/binding.gyp
[nodejs]Native module with libuv and v8::Promise on node-4
# -*- mode: python -*-
{
"targets": [
{
"include_dirs": ["<!(node -e \"require('nan')\")"],
"target_name": "TimerAndPromise",
"sources": [
"timer-and-promise.cc"
],
"conditions": [
@huruji
huruji / hello-world.cc
Created October 6, 2021 17:01 — forked from tejom/hello-world.cc
console.log v8
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <iostream>
@huruji
huruji / confirm.go
Created June 29, 2021 17:14 — forked from albrow/confirm.go
Go (golang): How to ask for user confirmation via command line
import (
"fmt"
"log"
"os"
"sort"
)
// askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and
// then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as
// confirmations. If the input is not recognized, it will ask again. The function does not return
@huruji
huruji / cloudSettings
Last active June 2, 2020 10:42
code_settings_2020
{"lastUpload":"2020-06-02T09:16:19.677Z","extensionVersion":"v3.4.3"}
@huruji
huruji / install_pipenv.sh
Created February 23, 2020 18:37 — forked from samredai/install_pipenv.sh
Python: Solution to 'Pipenv: Command Not Found' After 'pip install pipenv'
sudo -H pip install -U pipenv
# If you did a user install because you do not have sudo access, you have to modify your path to add your user folder
# The command on the next line tells you where your user folder is
# python3 -m site --user-base
PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin"
PATH="$PATH:$PYTHON_BIN_PATH"
@huruji
huruji / async-foreach.js
Created April 30, 2019 08:08 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@huruji
huruji / reset.js
Created February 23, 2019 07:57 — forked from 19h/reset.js
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}