Skip to content

Instantly share code, notes, and snippets.

View lalabuy948's full-sized avatar
🐙
¯\_(ツ)_/¯

lalabuy948

🐙
¯\_(ツ)_/¯
View GitHub Profile
import requests
response = requests.get('http://url.com')
for resp in response.history:
print(f'{resp.status_code} {resp.url}')
print(f'{resp.status_code} {resp.url}')
print(f'{response.status_code} {response.url}')
print(response.headers)
@lalabuy948
lalabuy948 / tornado-basic-auth.py
Created August 13, 2019 12:55
Tornado basic auth
# https://pypi.org/project/tornado-http-auth/
import tornado.ioloop
from tornado.web import RequestHandler, Application
from tornado_http_auth import DigestAuthMixin, BasicAuthMixin, auth_required
credentials = {'user1': 'pass1'}
# Example 1 (using decorator).
class MainHandler(DigestAuthMixin, RequestHandler):
@lalabuy948
lalabuy948 / GameController.swift
Last active November 9, 2019 22:51
Standalone WatchOS game setup
import WatchKit
import Foundation
class GameController: WKInterfaceController, WKCrownDelegate {
// Add SpriteKit outlet here
@IBOutlet weak var skInterface: WKInterfaceSKScene!
var gameScene:GameScene!
@lalabuy948
lalabuy948 / crownRotation.swift
Last active June 17, 2019 08:32
Crown rotate event for WatchKit
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController, WKCrownDelegate {
@IBOutlet var skInterface: WKInterfaceSKScene!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
@lalabuy948
lalabuy948 / background.swift
Last active June 17, 2019 08:54
Background snippet for spritekit
import UIKit
import SpriteKit
class gameScene: SKScene {
var background = SKSpriteNode(imageNamed: "bgimage")
override func sceneDidLoad(view: SKView) {
background.position = CGPoint(x: frame.size.width / 2, y: frame.size.height / 2)
background.zPosition = -1;
addChild(background)
@lalabuy948
lalabuy948 / simple_factory.py
Created February 11, 2019 10:46
Simple factory patter in Python3
class Button(object):
html = ""
def get_html(self):
return self.html
class Image(Button):
html = "<img></img>"

Чпок Челебок

Эта фраза запатентована Даниилом Поповым

Chpok Chelebok

This phrase is patented by Daniil Popov

for (var i=0; i < 101; i++){
if (i % 15 == 0) console.log("FizzBuzz");
else if (i % 3 == 0) console.log("Buzz");
else if if (i % 5 == 0) console.log("Fizz");
else console.log(i);
}
const http = require('http');
const link = 'http://387338.xyz:8000/status-json.xsl'
http.get(link, (resp) => {
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});