Skip to content

Instantly share code, notes, and snippets.

View ERPLookup
class ERP
def self.flat_bom(part_number)
Rails.cache.fetch("erp_flat_bom_#{part_number}") do
parts = {}
bom = ERP.get_bom(part_number)
bom.items.each do |item|
[... recursively go down to get every part in this indented BOM...]
end
parts
View splat.rb
s = Struct.new(:a,:b,:c)
a = [1,2,3]
b = s.new(*a)
puts b.a
puts b.b
puts b.c
View included.rb
module IncludableOne
def initialize
super
puts "IncludableOne::initialize"
register_on_save :includable_one_saved
end
def includable_one_saved
puts "Saved One"
end
end
View liquibase.xml
<changeSet author="liquibase-docs" id="createTable-example">
<createTable catalogName="cat"
remarks="A String"
schemaName="public"
tableName="person"
tablespace="A String">
<column name="address" type="varchar(255)"/>
</createTable>
</changeSet>
View functionTable.go
// Instruction - a struct which encapsulates a function pointer and also some information
// about the CPU instruction
type Instruction struct {
name string
dataSize int
function func(cpu *CPU)
cycles int
}
var instructions = []Instruction{
View gist:972309c4242f57a5d65e51a6168bd6eb
ADDR : instruction B C D E H L A SZ-X-P-C PW SP
0100 : 3E 01 MVI 00 00 00 00 00 00 00 00000010 0000
0102 : FE 02 CPI 00 00 00 00 00 00 01 00000010 0000
0104 : CA 00 00 JZ 00 00 00 00 00 00 01 10000111 0000
0107 : FE 01 CPI 00 00 00 00 00 00 01 10000111 0000
0109 : C2 00 00 JNZ 00 00 00 00 00 00 01 01010110 0000
010C : C3 11 01 JMP 00 00 00 00 00 00 01 01010110 0000
0111 : CD 17 01 CALL 00 00 00 00 00 00 01 01010110 0000
0117 : E1 POP HL 00 00 00 00 00 00 01 01010110 FFFE
0118 : 7C MOV AH 00 00 00 00 01 14 01 01010110 0000
View gist:ee473654a70c5456c4ee0dc96177d964
PS E:\Dropbox\8080\test> ruby .\server.rb
New connection
Current client count: 1
Client identified: 8080-golang .\test_roms\8080PRE.COM
New connection
Current client count: 2
Client identified: 8080-golang .\test_roms\8080EX1.COM
8080-golang .\test_roms\8080PRE.COM | 8080-golang .\test_roms\8080EX1.COM
ADDR OP B C D E H L A SZ-X-P-C SP | ADDR OP B C D E H L A SZ-X-P-C SP
0100 3E 00 00 00 00 00 00 00 00000010 0000 | 0100 C3 00 00 00 00 00 00 00 00000010 0000
View handles.py
class GameState:
def __init__(self):
self.handlers = {}
def default_handler(self,sw_number):
print( "Switch %s pushed!"%sw_number)
def on_switch(self,sw_number):
if sw_number in self.handlers:
self.handlers[sw_number]()
View bingo.py
import pygame
import random
bg_color = (255,255,255)
clock = pygame.time.Clock()
card = pygame.image.load("card.jpg")
card_size = card.get_rect()
running = True
@Insood
Insood / gist:f142493255127126fff052488ad5d3bd
Created Aug 7, 2017
i8080-core half_carry_table and !sub_half_carry_table
View gist:f142493255127126fff052488ad5d3bd
Add Index: (((A & 0x88) >> 1) | ((VAL & 0x88) >> 2) | ((A+B) & 0x88) >> 3)) & 0x7
A VAL RES ADD Meaning
0 0 0 0 Both A&Val are <0x7,
0 0 1 0 Both A&Val are <0x7, carry from 2 to 3 (but no half-carry)
0 1 0 1 There was a carry from 2 to 3 which caused a carry out of 3 (ie: 0111 + 1111 = 1 000)
0 1 1 0 There was no carry from 2 to 3, so no carry out of 3
1 0 0 1 There was a carry from 2 to 3 which caused a carry out of 3 (ie: 1111 + 0111 = 1 0000)
1 0 1 0 There was no carry from 2 to 3, so n ocarry out of 3
1 1 0 1 There was a carry out of 3 (1000 + 1000 = 1 0000)
You can’t perform that action at this time.