Skip to content

Instantly share code, notes, and snippets.

View tejastank's full-sized avatar

Tejas Tank tejastank

  • India
View GitHub Profile
@tejastank
tejastank / jenkins.py
Created March 30, 2019 12:28 — forked from aivaturi/jenkins.py
Simple wrapper to interact with Jenkins
import base64
import requests
INFO = 'api/json'
JOB_INFO = 'job/%s/api/json?depth=0'
JOB_NAME = 'job/%s/api/json?tree=name'
JOB_CONFIG = 'job/%s/config.xml'
CREATE_JOB = 'createItem?name=%s'
ENABLE_JOB = 'job/%s/enable'
DISABLE_JOB = 'job/%s/disable'
@tejastank
tejastank / amazon-rekognition.md
Created January 9, 2019 11:52 — forked from alexcasalboni/amazon-rekognition.md
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@tejastank
tejastank / client_kivy.py
Created January 4, 2019 08:03 — forked from rogererens/client_kivy.py
A Kivy client for the AutobahnPython WebSocket Echo server (Twisted-based)
# As the Kivy docs ( http://kivy.org/docs/guide/other-frameworks.html ) state:
# install_twisted_rector must be called before importing and using the reactor.
from kivy.support import install_twisted_reactor
install_twisted_reactor()
from autobahn.twisted.websocket import WebSocketClientProtocol, \
WebSocketClientFactory
class MyKivyClientProtocol(WebSocketClientProtocol):
@tejastank
tejastank / twitter_scrape.php
Created November 29, 2018 13:39
Twitter Analytics Scraper
<?php
// Call this with a cron script on a timed interval to scrape it
$user_agent = $_SERVER['HTTP_USER_AGENT']; // its possible you may wish to use an alternative user agent here
// First call gets hidden form field authenticity_token
// and session cookie
$ch = curl_init();
$sTarget = "https://twitter.com/";
curl_setopt($ch, CURLOPT_URL, $sTarget);
@tejastank
tejastank / object_pool.py
Created March 31, 2018 09:11 — forked from pazdera/object_pool.py
Example of `object pool' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `object pool' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@tejastank
tejastank / gist:08bc52a8b5dd23e2d27012ab11359e32
Created March 29, 2018 04:56 — forked from tamoyal/gist:10441108
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@tejastank
tejastank / add_feed.php
Created September 30, 2017 06:01 — forked from roborourke/add_feed.php
add_feed() example for WordPress
<?php
class custom_feed {
public $feed = 'custom-xml';
public function __construct() {
add_action( 'init', array( $this, 'init' ) );
import kivy
import os
import subprocess
kivy.require('1.0.7')
from kivy.animation import Animation
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.scatter import ScatterPlane
from kivy.uix.slider import Slider
@tejastank
tejastank / django_task_queue.md
Created July 11, 2017 09:55 — forked from tapanpandita/django_task_queue.md
Task queuing in Django with ZeroMQ

Task queuing in Django with ZeroMQ

Introduction

Here at Glitterbug Tech, Django is the lifeline of everything we make and we are big fans! Django doesn't get in the way and lets us write the language we love, python, while providing an amazing set of tools that makes creating web applications fast and fun. But, as you know, code is executed synchronously before you can send back a response. Which means when you are generating that report from your database which has a million rows, your client has to wait for a response while your application huffs and puffs trying to get everything ready (Unless he times out, in which case you receive angry calls while you try to explain what "502 Bad Gateway" means). Sometimes you just want to make your site more responsive by pushing time consuming tasks in the background ("Your comment has been posted!" while a zmq process works in the backend adding it to your db/caching layer/pushing it to followers/creating rainbows). Wha

@tejastank
tejastank / websocketserver.py
Created June 9, 2017 03:46 — forked from mumrah/websocketserver.py
Simple WebSockets in Python
import time
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
from threading import Thread
import signal