Skip to content

Instantly share code, notes, and snippets.

View ufo2mstar's full-sized avatar

Naren SivaSubramani ufo2mstar

View GitHub Profile
@ufo2mstar
ufo2mstar / machine.js
Created December 3, 2020 18:16
Generated by XState Viz: https://xstate.js.org/viz
const scriptMachine = Machine({
id: 'fetch',
initial: 'NO_SCRIPTS',
context: {
retries: 0,
},
states: {
NO_SCRIPTS: { on: { loadScript: 'SCRIPT_LOADING' } },
SCRIPT_LOADING: { on: { loadedScript: 'SCRIPT_READY', loadFailed: 'NO_SCRIPTS' } },
SCRIPT_READY: {
@ufo2mstar
ufo2mstar / machine.js
Created December 3, 2020 06:47
Generated by XState Viz: https://xstate.js.org/viz
const scriptMachine = Machine({
id: 'fetch',
initial: 'NO_SCRIPTS',
context: {
retries: 0,
},
states: {
NO_SCRIPTS: { on: { loadScript: 'SCRIPT_LOADING' } },
SCRIPT_LOADING: { on: { loadedScript: 'SCRIPT_READY', loadFailed: 'NO_SCRIPTS' } },
@ufo2mstar
ufo2mstar / machine.js
Created December 1, 2020 16:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ufo2mstar
ufo2mstar / win_10_password_scraper.rb
Created May 4, 2019 17:34
Quick little tool to scrape through your saved wifi passwords
str = `netsh wlan show profile`
profile_names = []
str.scan(/^.*Profile\s+: (.*)$/) {|x| profile_names << x[0]}
wifi_profiles = {}
nil_wifi_profiles = []
profile_names.each do |name|
cmd = "netsh wlan show profile name=#{name} key=clear"
str = `#{cmd}`
pswd = str[/^\s+Key Content\s+: (.*)$/, 1]
pswd ? wifi_profiles[name] = pswd : nil_wifi_profiles << name
@ufo2mstar
ufo2mstar / Ruby Binary Tree Print.rb
Created July 24, 2018 04:06
Ruby Binary Tree Print.. can also be modified to print more
class BinTree
class Node
attr_accessor :data, :left, :right
def initialize int
@data = int
end
def to_s
"Node: #{object_id}: data: #{data}"
@ufo2mstar
ufo2mstar / Jav tree print.java
Created July 23, 2018 13:50
Display tree from nodes
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ModelTreeNode {
final String name;
final List<ModelTreeNode> children;
private int offset = 0;
@ufo2mstar
ufo2mstar / my.ES6.notes.js
Created February 15, 2018 05:34
Just storing some of my experiments for future reference
const Card = () => {
class Parent {
mtd(){
return "parent"
}
}
class Mid extends Parent {
mtd(){
return super.mtd()+"mid"
@ufo2mstar
ufo2mstar / serve.rb
Created February 10, 2018 04:30
Quick Sinatra API
# server.rb
require 'sinatra'
require "sinatra/namespace"
require 'json'
# require 'mongoid'
# DB Setup
# Mongoid.load! "mongoid.config"
# Models
@ufo2mstar
ufo2mstar / dir_zipper.rb
Created October 19, 2017 19:56
Sample folder encrypter
require 'zip'
# This is a simple example which uses rubyzip to
# recursively generate a zip file from the contents of
# a specified directory. The directory itself is not
# included in the archive, rather just its contents.
#
# Usage:
# directoryToZip = "/tmp/input"
# output_file = "/tmp/out.zip"
@ufo2mstar
ufo2mstar / encode_html_b64.rb
Created October 19, 2017 19:52
HTML Base64 image Encoder
require 'base64'
class EncodeHtml
def initialize()
end
def img64(path)
ext = File.extname(path).strip.downcase[1..-1]
# enc = Base64.encode64(File.open(path, "rb").read) # gives pretty output