This is a common case in django ORM.
from django.db import models
class Author(models.Model):
events { | |
worker_connections 1024; | |
} | |
http { | |
default_type text/html; | |
access_log /dev/stdout; | |
sendfile on; | |
keepalive_timeout 65; |
#![feature(unboxed_closures)] | |
#![feature(core)] | |
#![feature(io)] | |
use std::old_io::stdio::{stdin}; | |
use std::collections::HashMap; | |
// This is our toy state example. | |
#[derive(Debug)] | |
struct State { |
from apps.images.signals import image_callback | |
def entry_upload_path(instance, filename): | |
return os.path.join("uploads", "blog", str(instance.id), filename) | |
class Entry(models.Model): | |
image = FileBrowseUploadField(max_length=250, upload_to=entry_upload_path) | |
post_save.connect(image_callback, sender=Entry) |
def debounced_wrap(func): | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
key = kwargs.pop("key") # it's required | |
call_count = kwargs.pop("call_count", 1) | |
count = cache.get(key, 1) | |
if count > call_count: | |
# someone called the function again before the this was executed | |
return None | |
# I'm the last call |
# http://eleparts.co.kr/data/design/product_file/SENSOR/gas/MH-Z19_CO2%20Manual%20V2.pdf | |
# http://qiita.com/UedaTakeyuki/items/c5226960a7328155635f | |
import serial | |
import time | |
def mh_z19(): | |
ser = serial.Serial('/dev/ttyAMA0', | |
baudrate=9600, | |
bytesize=serial.EIGHTBITS, | |
parity=serial.PARITY_NONE, |
from datetime import datetime | |
from sqlalchemy import Column, Integer, DateTime, ForeignKey | |
from sqlalchemy.orm import relationship | |
from sqlalchemy.ext.declarative import declared_attr | |
from flask_security import current_user | |
class AuditMixin(object): | |
created_at = Column(DateTime, default=datetime.now) | |
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now) |
extern crate ring; | |
use ring::aead::*; | |
use ring::pbkdf2::*; | |
use ring::rand::SystemRandom; | |
fn main() { | |
// The password will be used to generate a key | |
let password = b"nice password"; |
#![recursion_limit="512"] | |
// This script prints all cpu features which active in this build. | |
// There are 3 steps in usage of script: | |
// 1. get list of features using `rustc --print target-features` | |
// 2. put it into script (it has values actual for 2020-12-06 for x86-64 target). | |
// 3. run script. | |
fn pad_name(s: &str)->String{ | |
let mut res = s.to_string(); |