Skip to content

Instantly share code, notes, and snippets.

View AnjaneyuluBatta505's full-sized avatar

Anjaneyulu Batta AnjaneyuluBatta505

View GitHub Profile
@AnjaneyuluBatta505
AnjaneyuluBatta505 / kubernetes_commands.md
Created February 27, 2020 14:04 — forked from edsiper/kubernetes_commands.md
Kubernetes Useful Commands
@AnjaneyuluBatta505
AnjaneyuluBatta505 / redis_migrate.py
Created February 21, 2020 10:19 — forked from josegonzalez/redis_migrate.py
A simple script to migrate all keys from one Redis to another
#!/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
@AnjaneyuluBatta505
AnjaneyuluBatta505 / wifi.py
Created September 13, 2019 08:19 — forked from taylor224/wifi.py
Python WiFi Example
# -*- coding: utf-8 -*-
import wifi
def Search():
wifilist = []
cells = wifi.Cell.all('wlan0')
@AnjaneyuluBatta505
AnjaneyuluBatta505 / element_in_viewport.js
Created May 27, 2019 09:38
check if element is in viewport
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;
@AnjaneyuluBatta505
AnjaneyuluBatta505 / fetch-requests.js
Created April 12, 2019 10:36
requests lib using fetch
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])}`;
@AnjaneyuluBatta505
AnjaneyuluBatta505 / Loading.js
Created April 9, 2019 05:38
react js loading component
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'
},
@AnjaneyuluBatta505
AnjaneyuluBatta505 / tmux.md
Created January 26, 2019 09:23 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@AnjaneyuluBatta505
AnjaneyuluBatta505 / create_normal.html
Created January 4, 2019 09:12 — forked from taranjeet/create_normal.html
Django Library: Normal form js code
<!-- 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);
}
@AnjaneyuluBatta505
AnjaneyuluBatta505 / is_valid_lookup_field_for_model.py
Created November 8, 2018 07:08
django: check if given lookup string is valid for given model
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:
@AnjaneyuluBatta505
AnjaneyuluBatta505 / login_required.py
Created September 4, 2018 11:06 — forked from robgolding/login_required.py
Django Class-Based View Mixins: Part 1
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)