Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View forresty's full-sized avatar

Feng Ye forresty

View GitHub Profile
@forresty
forresty / overture
Last active May 17, 2020 10:59
openwrt overture init.d script
#!/bin/sh /etc/rc.common
START=91
USE_PROCD=1
PROG=/root/overture/overture-linux-arm
CONFIG=/root/overture/config.json
start_service() {
procd_open_instance
procd_set_param respawn
# A Swagger 2.0 (a.k.a. OpenAPI) definition of the Engine API.
#
# This is used for generating API documentation and the types used by the
# client/server. See api/README.md for more information.
#
# Some style notes:
# - This file is used by ReDoc, which allows GitHub Flavored Markdown in
# descriptions.
# - There is no maximum line length, for ease of editing and pretty diffs.
# - operationIds are in the format "NounVerb", with a singular noun.
@forresty
forresty / shell.py
Last active August 16, 2018 08:58
shell in 100 lines of python
#!/usr/bin/env python
import sys
import subprocess, shlex
import os
import readline # for history support
os.environ['PROMPT'] = '> '
def builtin_export(arg):
key, value = arg.split('=')
# 0. init the todo
# items = %w{ tomato potato eggs socks }
items = {
'tomato' => false,
'potato' => true,
'eggs' => false
}
def prompt(msg)
puts msg
class WagonString
def initialize(string)
# TODO: store the string as array of characters
end
def to_s
# TODO: convert into a Ruby String
end
def reverse
class BaseModel
attr_accessor :id
def initialize(attributes = {})
@id = attributes[:id]
end
end
class Patient
attr_accessor :id, :room
attr_reader :name
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@cured = attributes[:cured] || false
attributes[:room].add_patient(self)
require "nokogiri"
require "open-uri"
doc = Nokogiri::HTML(open("http://www.letscookfrench.com/recipes/find-recipe.aspx?s=strawberry&type=all"))
# puts doc.class
# CSS selector =>
# a => elements named a
# #logo => element with attr id=logo
require_relative 'tasks_view'
class AudibleTasksView < TasksView
def puts(args)
super
`say '#{args}'`
end
end
require_relative 'router'
require_relative 'tasks_controller'
require_relative 'tasks_repository'
repo = TasksRepository.new
controller = TasksController.new(repo)
Router.new(controller).run