Skip to content

Instantly share code, notes, and snippets.

@publicbull
publicbull / 2fa
Created April 3, 2020 05:41 — forked from MineRobber9000/2fa
2-factor authentication terminal app in Python
#!/usr/bin/env python
import os, os.path, stat, sys, base64
# TOTP lib inlined
import time, hmac, base64, hashlib, struct
def pack_counter(t):
return struct.pack(">Q", t)
@publicbull
publicbull / python_scripting.rst
Created November 26, 2017 07:33 — forked from jasonkeene/python_scripting.rst
Get started with writing your own python scripts to automate system tasks.

Python for System Admins / Operators

Installing Python

Most Unix/Linux systems come with python pre-installed:

$ python -V
@publicbull
publicbull / README.md
Created November 26, 2017 06:31 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.

For more about AWS and AWS Certifications and updates to this Gist you should follow me @leonardofed


@publicbull
publicbull / latency.txt
Created January 31, 2017 16:55 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
/**
* 引用不同的数据,会得到不同的地图切片
* 卫星(无地标) WGS-84 一般 GCJ-02
* <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
* 卫星(有地标) GCJ-02 一般 GCJ-02
* <script src="https://ditu.google.cn/maps/api/js?v=3.exp&sensor=false"></script>
*/
(function (map) {
var Converter = function () {

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
from mongoengine import *
class ProductList(Document):
name = StringField(required=True, unique=True)
def import_offers(self, offers):
for o in Offer.objects.filter(productlist=self.name):
o.old=True
o.save()
# -*- coding: utf-8 -*-
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
class MessageForm(forms.Form):
text_input = forms.CharField()
#!/usr/bin/env python
# -*- python -*-
#
# Plugin to track account balances on ingdirect.com.au, using selenium gymnastics to log in
#
# E.g.
# ln -s /usr/share/munin/plugins/ingdirect.py /etc/munin/plugins/ingdirect
#
# Needs (hint: pip install):
# selenium