Skip to content

Instantly share code, notes, and snippets.

View ufo2mstar's full-sized avatar

Naren SivaSubramani ufo2mstar

View GitHub Profile
@ufo2mstar
ufo2mstar / life.rb
Created March 10, 2016 15:59
kk lets see
# @author Naren Siva Subramani (https://github.com/ufo2mstar)
# @abstract .. because it represents, Life!!
# @deprecated Because there is always a Better Life out there!
## @since 0.0.1 (http://semver.org)
# @see https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
# == Conway's Game of Life
# Haha.. I've been meaning to implement this for a while now!!
# Finally got the chance to :)
# Hopefully we play the Game of Life well..
# PS: if only Real Life was this simple.. hmm.. maybe..
@ufo2mstar
ufo2mstar / logging_appenders_example.rb
Last active August 24, 2017 17:05
a working example to get the 'logging' gem setup and running for your application
require 'logging'
# Logger params
Logging.init :debug, :info, :warn, :error, :fatal
# Custom colour set
Logging.color_scheme('my_bright',
:levels => {
:debug => :blue,
:info => :green,
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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