Skip to content

Instantly share code, notes, and snippets.

@ohld
ohld / .travis.yml
Created May 16, 2019 10:20
Telegram webhook notification after a successful Travis CI build
language: node_js
node_js:
- "9"
dist: trusty
sudo: required
branches:
only:
- master
before_script:
- npm install -g @angular/cli
@ohld
ohld / download_instagram_mass_story_view_script.sh
Created June 16, 2019 19:54
Download script to watch millions of Instagram Stories
curl -0L https://raw.githubusercontent.com/instagrambot/instabot/master/examples/stories/watch_user_likers_stories.py --output watch_user_likers_stories.py
@ohld
ohld / morejuststore.py
Created July 18, 2019 15:59
Free File Storage (Morejust storage)
"""
More Just Store (https://www.producthunt.com/posts/morejust-store) can store your files for free.
BUT:
1) Your files will be publicly available
2) Max file size 100 Mb.
Can be very useful for your Indie/Hackathon projects.
"""
import requests
@ohld
ohld / .travis.yml
Created August 28, 2019 19:56
Travis config to run any python script on Travis machine
language: python
cache:
- pip
python:
- "3.6"
install:
- pip install -r requirements.txt
script:
- python bot.py
@ohld
ohld / like_my_likers_likers.py
Created August 28, 2019 20:03
Like the likers of my Instagram likers
import os
import time
import random
from instabot import Bot
def like_media_likers(bot, media, nlikes=2):
for user in bot.get_media_likers(media):
bot.like_user(user, nlikes)
return True
@ohld
ohld / dataframe_resume.py
Created October 15, 2019 09:50
Pandas DataFrame resume / summary for Data Analysis
def resumetable(df):
print(f"Dataset Shape: {df.shape}")
summary = pd.DataFrame(df.dtypes,columns=['dtypes'])
summary = summary.reset_index()
summary['Name'] = summary['index']
summary = summary[['Name','dtypes']]
summary['Missing'] = df.isnull().sum().values
summary['Uniques'] = df.nunique().values
summary['First Value'] = df.loc[0].values
summary['Second Value'] = df.loc[1].values
@ohld
ohld / index.py
Created October 15, 2019 16:44
Now sh (Zeit co) simple Serverless Telegram echo bot (in Python)
import os
import logging
import telegram
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/api', methods=['POST'])
def api():
bot = telegram.Bot(token=os.getenv("TELEGRAM_TOKEN"))
@ohld
ohld / now.json
Created October 15, 2019 16:54
Ziet co config to use secret environment variables in python projects
{
"builds": [{
"src": "index.py", "use": "@now/python"
}],
"routes": [
{ "src": "/(.*)", "dest": "index.py" }
],
"env": {
"TELEGRAM_TOKEN": "@telegram-token"
}
@ohld
ohld / admin.py
Last active November 9, 2020 20:57
Django Admin action with intermediate page example
# your_app/admin.py
# ... imports
@admin.register(User)
class UserAdmin(admin.ModelAdmin):
actions = ['broadcast'] # register method as action
def broadcast(self, request, queryset):
if 'apply' in request.POST: # if user pressed 'apply' on intermediate page
@ohld
ohld / broadcast_message.html
Created October 30, 2019 10:31
Django Admin action Intermediate page code template
<!-- my_django_app/templates/admin/broadcast_message.html -->
<!-- This block will be included to django admin basic template -->
{% extends "admin/base_site.html" %}
{% block content %}
<form action="" method="post">{% csrf_token %}
<!-- The code of the form with all input fields will be automatically generated by Django -->
{{ form }}
<!-- Show the list of selected objects on the previous step -->