Skip to content

Instantly share code, notes, and snippets.

## to_b methods dependant on ossy string class
class Dex
def initialize
## create data folder if it doesnt exist
@data_path=HOMEDIR+"/app/dex/data"
if File.exist?(@data_path)==false
Dir.mkdir(HOMEDIR+"/app/dex/data")
end
@bankfile=0
if File.exist?(@data_path+"/"[email protected]_s+".db")==false
@thomasjslone
thomasjslone / Exponate - Ruby vs. Python ##BUG
Last active November 6, 2021 21:57
ya there be bugs in there
##
## Python
##
def exp(n):
c=2
e=2
rv=False
while c<=n:
e=2
@thomasjslone
thomasjslone / Prime - Python vs. Ruby
Created September 4, 2021 10:47
The ruby prime method converted to python.
#
# Python
#
def prime(num):
rv=True;c=1;l=num-1
while c<l:
c=c+1
if int(str(num/c).split('.')[-1])==0:
rv=False;c=num
return rv
## all 256 ascii characters
CHARS = [] ; c = 0 ; 256.times{ CHARS << c.chr.to_s ; c += 1 }
## every 8 bit binary number in order
BINARY = [] ; c = 0 ; 256.times { b = c.to_s(2) ; until b.to_s.length == 8 ; b = "0" + b.to_s ; end ; BINARY << b ; c += 1 }
## every hexicdeimal number in order upto 256 ordinals
HEX = [] ; c = 0 ; 256.times { h = c.to_s(16) ; if h.length == 1 ; h = "0" + h.to_s ; end ; HEX << h ; c += 1 }
## a list of all 8 bit byte codes for the ascii characters
BYTES = [] ; HEX.each do |h| ; BYTES << "\\x" + h ; end
def only_letters? s ;s.upcase.delete("ABCDEFGHIJKLMNOPQRSTUVWXYZ").empty?;end
@thomasjslone
thomasjslone / web_crawler1.1.rb
Last active April 18, 2022 14:39
webcrawler vers 1
# webcrawler 1.1 created 2021.05.04 last updated 2021.05.05 j.thomas
# starts with a basepage and grabs links as it finds them in each page while noting instances of search term appearences in pages and links
require 'uri';require 'open-uri'
class Web_Crawler
def initialize
@case_sensitivity=false ## wether caps is ignored when looking for search term
@counter=0 ##number of loops executed\pages crawled
@invalid_counter=0 ## number of invalid pages checked
@already_searched=[] ## links to not crawl again
@search_term=''
@thomasjslone
thomasjslone / web_crawler.rb
Created May 5, 2021 03:53
basic blind ruby webcrawler with search terms
# webcrawler 1.0 created 2021.05.04 ## follow the term across every connected link blindly
require 'uri';require 'open-uri'
class Web_Crawler
def initialize
@case_sensitivity=false
end
def crawl(base_page,term)
@counter=0 ##number of loops executed\pages crawled
@search_term=term.to_s ## a string to search pages for
@thomasjslone
thomasjslone / ossy.rb
Created November 25, 2017 19:40
ossy 1404
## Ossy Core - Version 1.4.0.0
## OCT21-2017 - Thomas J. Slone
CORE_VERSION = "1.4.0.3" ; CORE_DATE = "2017.11.22.10.40.21"
CORE_AUTHOR = "Thomas J. Slone" ; CORE_MANUFACTURER = "Tomtech"
CORE_NAME = "Ossy" ; CORE_EDITION = " Another edition. "
CORE_INIT_TIME = Time.now ; CORE_BOOT_LOG = []
MAIN = self
ADMIN = "admin" ; PASSWORD = ""
require "open-uri"
require "net/http"
require "openssl"
@page = "unloaded"
@html = "unloaded"
uri = URI.parse(ARGV[0] || 'https://en.wikipedia.org/wiki/Hydrogen')
http = Net::HTTP.new(uri.host, uri.port)
if uri.scheme == "https" # enable SSL/TLS
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@thomasjslone
thomasjslone / dictionary.dex
Created April 14, 2017 11:11
data file for dictionary v 1.1.1
["a", "aalar", "aaron", "aaronite", "aaronites", "aasbai", "abacuc", "abaddon", "abadias", "abagtha", "abana", "abanah", "abandon", "abandoned", "abandonment", "abaran", "abarim", "abaron", "abase", "abased", "abasement", "abases", "abaseth", "abashed", "abasing", "abate", "abated", "abatement", "abateth", "abba", "abda", "abdeel", "abdemelech", "abdenago", "abdi", "abdias", "abdiel", "abdon", "abed", "abel", "abela", "abelcheramim", "abeldomum", "abelmahula", "abelmaim", "abelmehula", "abelmeula", "abenboen", "abes", "abesalom", "abesan", "abessalom", "abez", "abgatha", "abhor", "abhorred", "abhorrence", "abhorrest", "abhorreth", "abhorring", "abi", "abia", "abiah", "abialbon", "abiam", "abiasaph", "abiathar", "abib", "abida", "abidah", "abidan", "abide", "abides", "abidest", "abideth", "abiding", "abiel", "abiezer", "abiezrite", "abiezrites", "abigabaon", "abigail", "abigal", "abihaiel", "abihail", "abihu", "abihud", "abijah", "abijam", "abilene", "abilina", "ability", "abimael", "abimelech", "abinadab", "a
## Name: Rios Methods
## Version: 1.0.6
## Release: 2017-1-5
## Manufacturer: Thomas Tech
def splice(str,b,e)
res = []
loop do
p = str[/#{b}(.*?)#{e}/m, 1].to_s
if p.to_s.length == 0