Skip to content

Instantly share code, notes, and snippets.

View snowman's full-sized avatar
💭
I may be slow to respond.

snowman snowman

💭
I may be slow to respond.
View GitHub Profile
theta = linspace(0, 2*pi, 40);
phi = linspace(0, pi, 40);
[theta, phi] = meshgrid(theta, phi);
rho=1;
x = rho * sin(phi) .* cos(theta);
y = rho * sin(phi) .* sin(theta);
z = rho * cos(phi);
@snowman
snowman / promise_demo_1.js
Last active July 21, 2018 05:38
Javascript promise
// http://jsfiddle.net/mkjh2ev5/1245/
let cleanRoom = function() {
return new Promise(function(resolve, reject) {
resolve('Cleaned The Room');
});
};
let removeGarbage = function(message) {
return new Promise(function(resolve, reject) {
@snowman
snowman / async.js
Last active July 21, 2018 05:15
Javascript SetTimeout asynchronomous Test...
var changed = false;
setTimeout(function () {
console.log("I'm hacking in setTimeout~~~");
changed = true;
})
while (true) {
if (changed) {
console.log("The system has been hacked by outer program. Exiting...");
@snowman
snowman / laughing-man.svg
Created May 23, 2019 14:52 — forked from johan/laughing-man.svg
The Laughing Man (Ghost in the Shell), 1000 byte SVG :-)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@snowman
snowman / alexa.js
Created June 22, 2019 10:56 — forked from chilts/alexa.js
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
import os
import sys
import re
import hashlib
import csv
import time
import locale
import getopt
/*!
* jQzoom Evolution Library v2.3 - Javascript Image magnifier
* http://www.mind-projects.it
*
* Copyright 2011, Engineer Marco Renzi
* Licensed under the BSD license.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@snowman
snowman / mpvhistory.lua
Created November 12, 2019 02:02 — forked from garoto/mpvhistory.lua
Simple media logger Lua script for mpv
-- Not my code: originally from https://redd.it/3t6s7k (author deleted; failed to ask for permission).
-- Only tested on Windows. Date is set to dd/mmm/yy and time to machine-wide format.
-- Save as "mpvhistory.lua" in your mpv scripts dir. Log will be saved to mpv default config directory.
-- Make sure to leave a comment if you make any improvements/changes to the script!
local HISTFILE = (os.getenv("APPDATA") or os.getenv("HOME").."/.config").."/mpv/mpvhistory.log";
mp.register_event("file-loaded", function()
local title, logfile;
@snowman
snowman / gpg-import-and-export-instructions.md
Created November 13, 2019 05:52 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@snowman
snowman / makepkg_overview.rst
Created December 20, 2019 14:37 — forked from Earnestly/makepkg_overview.rst
A brief overview of the process involved in creating a pacman package.

A Brief Tour of the Makepkg Process: What Makes a Pacman Package

Introduction

This is a terse document covering the anatomy of a package built for the pacman package manager.

The following example commands can mostly run verbatim to manually create a