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
frontend seaweb | |
bind 0.0.0.0:80 | |
bind 0.0.0.0:443 ssl crt /etc/haproxy/certs/ alpn h2,http/1.1 | |
mode http | |
## Force to HTTPS | |
http-request redirect scheme https unless { ssl_fc } | |
http-request set-header X-Forwarded-Proto https | |
http-request set-header X-Forwarded-Host %[req.hdr(Host)] |
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
Vue.directive('datepicker', { | |
bind: function (el, binding, vnode, oldVnode) { | |
$(el).datepicker({ | |
onSelect: function (date) { | |
vnode.context.date = date; | |
} | |
}); | |
}, | |
update: function (el, binding, vnode, oldVnode) { | |
$(el).datepicker('setDate', binding.value); |
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
_db = None | |
def set_db(db): | |
global _db | |
_db = db | |
def create_invoice(customer_id, line_items): | |
customer = customer_by_id(customer_id) | |
invoice_id = new_invoice_id() | |
insert_record('invoice', id=invoice_id, customer_id=customer_id) |
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
def create_invoice(db, customer_id, line_items): | |
customer = customer_by_id(db, customer_id) | |
invoice_id = new_invoice_id(db) | |
insert_record(db, 'invoice', id=invoice_id, customer_id=customer_id) | |
for item in line_items: | |
insert_record(db, 'line_item', invoice_id=invoice_id, | |
amount=item.amount, product=item.product_id) | |
return invoice_id | |
def customer_by_id(db, customer_id) |
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
type SQLLogger struct { | |
e SQLExecutor | |
} | |
func (s *SQLLogger) ExecuteSQL(sql string) []SQLRecord { | |
r := s.e.ExecuteSQL(sql) | |
fmt.Printf("SQL (%d records): %v", len(r), sql) | |
return r | |
} |
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
// Provider interface for your object | |
type PatientProvider interface { | |
PatientByID(id int) Patient | |
InactivePatients() []Patient | |
} | |
// Dependency interface needed by object | |
type SQLExecutor interface { | |
ExecuteSQL(sql string) []SQLRecord | |
} |
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
// Credit to https://coderwall.com/p/ik5xxa/run-a-subprocess-and-connect-to-it-with-golang | |
package main | |
import ( | |
"fmt" | |
"os/exec" | |
"os" | |
) | |
func exec_command(program string, args ...string) { |
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
package main | |
import ( | |
"fmt" | |
"github.com/Knetic/govaluate" | |
"os" | |
"bufio" | |
) | |
func main() { |
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
""" Proof of concept of looking up a matching value based on multiple indexes | |
by reverse sorting and searching the combinations. O^log n I believe. | |
""" | |
from itertools import combinations | |
class Lookup: | |
def __init__(self, name=None): | |
self.name = name | |
self.index = {} |
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 sys | |
def write_png(filename, width, height, rgb_func): | |
import zlib | |
import struct | |
import array | |
def output_chunk(out, chunk_type, data): | |
out.write(struct.pack("!I", len(data))) |
NewerOlder