Skip to content

Instantly share code, notes, and snippets.

View ntpz's full-sized avatar

Vladislav Tolkachev ntpz

  • Nizhny Novgorod, Russia
View GitHub Profile
<?
session_start();
function login($username, $password) {
if($password == '53cr3t') {
return array('username' => $username);
} else {
return null;
}
}
@ntpz
ntpz / Makefile
Created May 2, 2015 15:42
Makefile for Google app engine project
PYTHON = python
APPENGINE = /usr/local/google_appengine
APPCFG = $(PYTHON) $(APPENGINE)/appcfg.py
APP_ID = (YOUR-APP-ID)
EMAIL = (YOUR-EMAIL)
SERVE_PORT = 8080
ADMIN_PORT = 8000
SERVE_ADDRESS = 0.0.0.0
DATASTORE_PATH = ./datastore.sqlite3
from dateutil import tz
from jinja2 import Undefined
client_timezone = tz.gettz('PST8PDT') # timezone to translate to
@app.template_filter()
def dateformat(value, format=None, rebase=True):
if value is None or isinstance(value, Undefined):
return ''
#!/usr/bin/env python
# Copyright, license and disclaimer are at the end of this file.
# This is the latest, enhanced version of the asizeof.py recipes at
# <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/546530>
# <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/544288>
'''This module exposes 10 functions and 2 classes to obtain lengths
and sizes of Python objects (for Python 2.2 or later [1]).
@ntpz
ntpz / calmdl.py
Created January 22, 2017 12:04
calm.com audio exportee
import os
import requests
import json
import re
import urlparse
import unicodedata
URL = 'https://api.calm.com/programs/sections'
@ntpz
ntpz / c9_python_workspace_init.sh
Created February 23, 2017 13:42
Set up python dev environment on Cloud9
#!/bin/bash
cd ~/workspace
# Upgrade pip
wget https://bootstrap.pypa.io/get-pip.py
sudo -H python get-pip.py
sudo -H python3 get-pip.py
# Install python packages
@ntpz
ntpz / rstat.py
Created November 28, 2017 21:33
Usage stats extractor
#!/usr/bin/env python
"""
extract usage stats
requirements:
- peewee
- requests
"""
@ntpz
ntpz / passthrough.js
Created November 27, 2018 05:41
Node.js request forwarder
/*
node.js request forwarder
Usage:
const express = require('express');
const passthrough = require('./passthrough');
const app = express();
app.enable('trust proxy');
@ntpz
ntpz / bookmarks2json.js
Created December 19, 2018 21:50
Convert chrome bookmarks file to json
const fs = require('fs'),
path = require('path'),
{ promisify } = require('util'),
readFileAsync = promisify(fs.readFile),
writeFileAsync = promisify(fs.writeFile),
inPath = path.join(__dirname, 'bookmarks.html'),
outPath = path.join(__dirname, 'bookmarks.json'),
linkRx = /<A([^>]+)>([^<]+)<\/A>/ig;
@ntpz
ntpz / capture_hls.md
Created October 16, 2019 07:20 — forked from s4y/capture_hls.md
Capture an HLS stream from the beginning with ffmpeg
ffmpeg -live_start_index -99999 -i 'https://….m3u8' -c copy something.ts