Skip to content

Instantly share code, notes, and snippets.

View bitnom's full-sized avatar
💭
forever building

bitnom bitnom

💭
forever building
View GitHub Profile
@bitnom
bitnom / install-nvidia-docker.sh
Created February 26, 2021 00:51
install nvidia docker on Linux
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
curl -s -L https://nvidia.github.io/nvidia-container-runtime/experimental/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
def blocking_io():
print(f"start blocking_io at {time.strftime('%X')}")
# Note that time.sleep() can be replaced with any blocking
# IO-bound operation, such as file operations.
time.sleep(1)
print(f"blocking_io complete at {time.strftime('%X')}")
async def main():
print(f"started main at {time.strftime('%X')}")
import aiohttp
from aiohttp_socks import ProxyType, ProxyConnector, ChainProxyConnector
async def fetch(url):
connector = ProxyConnector.from_url('socks5://user:[email protected]:1080')
### or use ProxyConnector constructor
# connector = ProxyConnector(
# proxy_type=ProxyType.SOCKS5,
@bitnom
bitnom / css-popup-demo.markdown
Created November 19, 2019 04:33
css popup demo
@bitnom
bitnom / user-alias-gun.js
Created August 11, 2019 20:19
gun doesn't create user in alias check
$('#up').on('click', function(e) {
e.preventDefault();
let aliasIn = $('#alias').val()
let passIn = $('#pass').val()
gun.get("~@" + aliasIn).once(function (uAlias) {
if (uAlias === undefined) {
console.log("alias undefined, registering.")
user.create($('#alias').val(), $('#pass').val(), function (ack) {
console.log("create user ack: " + ack)
user.auth($('#alias').val(), $('#pass').val());
@bitnom
bitnom / gun-pub.js
Created August 11, 2019 03:23
Gun creates multiple public keys per-user
gun.on('auth', function(){
$('.loggedOut').hide();
$('.loggedIn').show();
user.get('said').map().once(UI);
user.get('alias').val(function(name){
//console.log(name)
if(upPub !== null){
let peers = gun.get('peers')
peers.once(function(data){
let uSet = {name: name, pub: upPub}
@bitnom
bitnom / setu.js
Created July 25, 2019 15:57
gun setu() - add to set only if unique
function setu(node, item){
let unique = true
let comparison = function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if ((aProps.length-1) === bProps.length) {
for (let i = 1; i < aProps.length; i++) {
let propName = aProps[i];
// values of same property
@bitnom
bitnom / recall.js
Created July 19, 2019 15:26
Gun User Recall
user.recall(6 * 60, { // minutes
session: true,
hook: function(props) { // { iat, exp, remember }
console.log("got to hook")
var passed = (Time.now() / 1000) - props.iat; // seconds internally
return (passed < exp) ? ((props.exp += passed) && props) : props;
}
}).then(function(ack) {
console.log("got to then")
if (ack && ack.sea) {
@bitnom
bitnom / setu.js
Created July 18, 2019 15:24
gun set if unique (Working)
function setu(node, item){
let unique = true
node.map().once(function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if ((aProps.length-1) === bProps.length) {
for (let i = 1; i < aProps.length; i++) {
let propName = aProps[i];
// values of same property
@bitnom
bitnom / setu.js
Created July 18, 2019 15:00
set if unique
function setu(node, item){
let unique = true
node.map().once(function (data) {
let aProps = Object.getOwnPropertyNames(data);
let bProps = Object.getOwnPropertyNames(item);
// number of properties
if (aProps.length === bProps.length) {
console.log("same len")
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];