Skip to content

Instantly share code, notes, and snippets.

@y1n0
y1n0 / veryactive.py
Last active May 12, 2018 23:15
[veryactivebot](https://t.me/veryactivebot) backend
"""
This is the code running the Telegram bot @veryactivebot
(https://t.me/veryactivebot). It ensure that the bot is
always doing an action: typing, uploading a document,
sending audio.. If anyone, for whatever mysterious reason,
finds this code useful, they can use as they want, as long
as they refer to its source.
In order for the bot to work, its authentification token is
needed. This token can be specified in an environment
@y1n0
y1n0 / baisc_fstring.py
Created April 14, 2018 17:54
a method to format strings in an f-strings-like way.
name = "Begovich"
template = "Hello, {name}"
print(template.format(**globals()))
@y1n0
y1n0 / switch_lang.sh
Created September 16, 2017 00:01
A tweak to show a language indicator in i3wm's i3status
#!/bin/bash
# You'll need to set a keybind to run this script
# It will change the keyboard layout and create a file in `/tmp`
# indicating the current layout lang.
# Use the module `path_exists` of i3status to check
# if the file (named here `currlang_ar`) is created
layout=$(setxkbmap -query | grep layout | cut -d: -f2 | sed -e 's/^[[:space:]]*//')
if [ $layout == 'us' ] ; then
from bs4 import BeautifulSoup
import requests
soup = BeautifulSoup(requests.get('http://nytimes.com').content, 'html.parser')
for i in soup(class_='story-heading'):
print(i.text.strip())
@y1n0
y1n0 / tic_tac_toe.py
Created March 1, 2017 00:59
practicepython.org; ex 24
#!/usr/bin/python3.5
def grid(x=1, y=1):
hor_line = ' ---'
ver_line = '| '
print(hor_line*x)
for i in range(y):
print(ver_line*x+'|')
print(hor_line*x)
#!/usr/bin/python3.5
from collections import Counter
import json
def help():
print('Available options:')
print('\t\'add <name>\' to add a new entry')
print('\t\'show <name|all>\' to show the birthday.')
@y1n0
y1n0 / cows_bulls.py
Created February 27, 2017 22:42
practicepython.org's ex #18
#!/usr/bin/python3.5
import random
def main():
# the random number is in form of list
num = [random.randint(0, 9) for i in range(4)]
tries = 0
print(num)
@y1n0
y1n0 / hangman.py
Created February 27, 2017 19:44
the hangman game. Exercise 30 from practicepython.org
#!/usr/bin/python3.5
import random
def pickWord():
with open('hang_words.txt', 'r') as f:
x = random.randint(0, 267750)
# print x
for i in range(267750):
line = f.readline()
if x==i:
@y1n0
y1n0 / index.html
Last active February 3, 2017 16:18
contact-manager
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contact manager</title>
<style type="text/css">
body {
display: flex;
height: 100vh;