Skip to content

Instantly share code, notes, and snippets.

@abom
abom / bytes_from_seed.py
Created July 16, 2021 14:48
Get bytes from ed25519 key seed
import sys
from jumpscale.loader import j
def from_seed(seed):
seed = seed.strip()
if seed.startswith("0x"):
seed = seed[2:]
@abom
abom / mappedfactory.py
Created April 16, 2020 21:23
a factory with name mapping for js-ng
"""
Redis client
"""
from jumpscale.core.base import Base, StoredFactory
from jumpscale.core.base import fields
class Project(Base):
name = fields.String()
@abom
abom / test.py
Created March 24, 2020 19:12
example to how the usage will be like
from csr1000v import Router
host, port = "172.18.0.3", 55443
router = Router(host, port, "abdo", "1234")
print(router.token)
print(router.processes.get_total_memory_usage())
@abom
abom / simple_webix_app.html
Created February 23, 2020 19:26
ansihtml.js can be found here https://github.com/agnoster/ansi2html/blob/master/lib/index.js (just copy and rename).
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="codebase/webix.css" type="text/css">
<script src="codebase/webix.js" type="text/javascript"></script>
<script src="ansi2html.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
webix.ui({
from Jumpscale import j
class Package(j.baseclasses.threebot_package):
def start(self):
for port in (443, 80):
website = self.openresty.get_from_port(port)
locations = website.locations.get(name=f"unlock_service_{port}_locations")
include_location = locations.get_location_custom(f"unlock_service_includes_{port}")
@abom
abom / index.html
Created May 22, 2019 14:05 — forked from mie00/trip.html
plotting an entire trip using location history from google and google maps javascript api
<!DOCTYPE html>
<html>
<!--
usage:
1. install jq for json parsing.
2. go here https://takeout.google.com/settings/takeout and download "Location history" in json format and save it as location.json.
3. run `cat location.json|jq '.locations | map(select(has("accuracy"))) | map({lat: (.latitudeE7 / 10000000), lng: (.longitudeE7 / 10000000), accuracy: .accuracy, timestamp: (.timestampMs | tonumber / 1000)})' > google.json`
4. cp google.json google.js.
5. add `var points = ` to the beginning of google.js file.
@abom
abom / WinUSBFromLinux.md
Created March 31, 2018 22:30 — forked from kuznero/WinUSBFromLinux.md
How to make Windows 7 USB flash install media from Linux?

How to make Windows 7 USB flash install media from Linux?

StackOverflow

  • Install ms-sys - if it is not in your repositories, get it here. Or alternatively, make sure lilo is installed (but do not run the liloconfig step on your local box if e.g. Grub is installed there!)
  • Check what device your USB media is assigned - here we will assume it is /dev/sdb. Delete all partitions, create a new one taking up all the space, set type to NTFS (7), and remember to set it bootable:
# cfdisk /dev/sdb
or fdisk /dev/sdb (partition type 7, and bootable flag)
@abom
abom / calc_uncomp_size.py
Last active February 22, 2018 17:22
Get uncompressed size of all zip files inside a directory
# encoding: utf-8
from __future__ import unicode_literals
import os
import zipfile
def is_zip_file(path):
return os.path.isfile(path) and zipfile.is_zipfile(path)
@abom
abom / bills.py
Last active November 9, 2018 13:45 — forked from mie00/bills.py
For bills and stuff
#!/usr/bin/env python
def calc(gross, delivery, **d):
"""
usage:
>>> calc(120, 9,
Ashraf=40,
Thabet=20,
Awadi=20,
Ghanem=20)
@abom
abom / springer-free-maths-books.md
Created December 30, 2015 00:44 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links