This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' } }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BinTree | |
class Node | |
attr_accessor :data, :left, :right | |
def initialize int | |
@data = int | |
end | |
def to_s | |
"Node: #{object_id}: data: #{data}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Card = () => { | |
class Parent { | |
mtd(){ | |
return "parent" | |
} | |
} | |
class Mid extends Parent { | |
mtd(){ | |
return super.mtd()+"mid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# server.rb | |
require 'sinatra' | |
require "sinatra/namespace" | |
require 'json' | |
# require 'mongoid' | |
# DB Setup | |
# Mongoid.load! "mongoid.config" | |
# Models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder