Helper setup to edit .yaml files with Vim:
List of general purpose commands for Kubernetes management:
Helper setup to edit .yaml files with Vim:
List of general purpose commands for Kubernetes management:
#!/usr/bin/env python | |
import argparse | |
import redis | |
def connect_redis(conn_dict): | |
conn = redis.StrictRedis(host=conn_dict['host'], | |
port=conn_dict['port'], | |
db=conn_dict['db']) | |
return conn |
# -*- coding: utf-8 -*- | |
import wifi | |
def Search(): | |
wifilist = [] | |
cells = wifi.Cell.all('wlan0') |
function elementInViewport2(el) { | |
var top = el.offsetTop; | |
var left = el.offsetLeft; | |
var width = el.offsetWidth; | |
var height = el.offsetHeight; | |
while(el.offsetParent) { | |
el = el.offsetParent; | |
top += el.offsetTop; | |
left += el.offsetLeft; |
const getQueryString = params => { | |
return Object.keys(params) | |
.map(k => { | |
if (Array.isArray(params[k])) { | |
return params[k] | |
.map(val => `${encodeURIComponent(k)}[]=${encodeURIComponent(val)}`) | |
.join("&"); | |
} | |
return `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`; |
import React, { Component } from "react"; | |
import { ActivityIndicator, View } from "react-native"; | |
import {StyleSheet} from 'react-native' | |
const styles = StyleSheet.create({ | |
loading: { | |
flex: 1, | |
flexDirection: "row", | |
alignItems: 'center' | |
}, |
<!-- create_normal.html :: part 4 --> | |
<script type='text/javascript'> | |
function updateElementIndex(el, prefix, ndx) { | |
var id_regex = new RegExp('(' + prefix + '-\\d+)'); | |
var replacement = prefix + '-' + ndx; | |
if ($(el).attr("for")) $(el).attr("for", $(el).attr("for").replace(id_regex, replacement)); | |
if (el.id) el.id = el.id.replace(id_regex, replacement); | |
if (el.name) el.name = el.name.replace(id_regex, replacement); | |
} |
from django.db.models.constants import LOOKUP_SEP | |
from django.core.exceptions import FieldDoesNotExist | |
# django: check if given lookup string is valid for given model | |
def is_valid_lookup_field(model, lookup): | |
# will return first non relational field's verbose_name in lookup | |
for part in lookup.split(LOOKUP_SEP): | |
print(part) | |
try: |
class LoginRequiredMixin(object): | |
""" | |
View mixin which requires that the user is authenticated. | |
""" | |
@method_decorator(login_required) | |
def dispatch(self, request, *args, **kwargs): | |
return super(LoginRequiredMixin, self).dispatch( | |
self, request, *args, **kwargs) |