Skip to content

Instantly share code, notes, and snippets.

Avatar

Saeb sae13

View GitHub Profile
View apkdelbot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler, StringRegexHandler, BaseFilter)
from telegram import MessageEntity
import logging
group_admins = {}
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
@sae13
sae13 / php iran phone regex
Created Jul 7, 2020
رجکس شماره مبایل
View php iran phone regex
<?php
$a = "9133917225";
$mobile_pattern = "/^(\s)*(\+98|0098|98|0)?(9\d{9})(\s*|$)/";
preg_match($mobile_pattern,$a,$matches);
if(sizeof($matches) === 5)
var_dump($matches[3]);
View django genericAPIView
import django_filters
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from rest_framework import status
from rest_framework.generics import GenericAPIView
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, CreateModelMixin, DestroyModelMixin, \
UpdateModelMixin
from rest_framework.request import Request
from rest_framework.response import Response
View fish shell function
#alias login "curl 'http://devapp01.icico.net.ir/oauth/token' -s -H 'Authorization: Basic U2FsZXM6cGFzc3dvcmQ=' -H 'Content-Type: application/x-www-form-urlencoded' --data 'grant_type=password&username=saeb&password=password'|jq '.access_token'"
#alias auth2 "echo \"Authorization: Bearer \" ( string replace -a '\"' '' (login))"
function nicico
set login (curl 'http://devapp01.icico.net.ir/oauth/token' -s -H 'Authorization: Basic U2FsZXM6cGFzc3dvcmQ=' -H 'Content-Type: application/x-www-form-urlencoded' --data 'grant_type=password&username=saeb&password=password'|jq '.access_token')
set auth2 (echo "Authorization: Bearer " ( string replace -a '"' '' $login))
# echo $login $auth2
curl -s -H $auth2 $argv
end
@sae13
sae13 / wordpressTextDomainAction
Created Mar 10, 2020
load wordpress plugin text domain on init
View wordpressTextDomainAction
{
load_plugin_textdomain('gflimitbyday',
false,
basename(dirname(__FILE__)) . '/languages');
}
add_action('init','gflimitbyday_add_languages');
@sae13
sae13 / awk
Last active Nov 25, 2019
bash examples
View awk
ip a|awk '{if ($1 ~ /^[0-9]:/) print $1 ; if (/inet/) print $2}'
1:
127.0.0.1/8
::1/128
2:
172.16.6.164/24
fe80::681a:78de:211:28d2/64
3:
192.168.122.1/24
4:
View xlsx.java
public static void getUserName(String xlsLocation) throws IOException {
FileInputStream file = new FileInputStream( new File(xlsLocation));
Workbook workbook = new XSSFWorkbook(file);
Sheet sheet = workbook.getSheetAt(0);
for(Row row: sheet)
{
Cell tenCell = row.getCell(0);
tenCell.setCellType(CellType.STRING);
Cell sixCell = row.getCell(1);
sixCell.setCellType(CellType.STRING);
View SendSMS.py
from openpyxl import load_workbook
from openpyxl.worksheet.worksheet import Worksheet
from requests import get
xlsxFileAddress = "/home/saeb/PycharmProjects/SendSMS/xlsx/139804.xlsx" #xlsx file
def sendToSMSCenter(phone="09133917225", text="سلام دنیا"):
params = {
"from": "+98100020400",
View fontsahelnahid.css
@font-face {
font-family: Sahel;
src: url('https://cdn.jsdelivr.net/gh/rastikerdar/sahel-font@latest/dist/Farsi-Digits/Sahel-FD.eot');
src: url('https://cdn.jsdelivr.net/gh/rastikerdar/sahel-font@latest/dist/Farsi-Digits/Sahel-FD.eot?#iefix') format('embedded-opentype'),
url('https://cdn.jsdelivr.net/gh/rastikerdar/sahel-font@latest/dist/Farsi-Digits/Sahel-FD.woff') format('woff'),
url('https://cdn.jsdelivr.net/gh/rastikerdar/sahel-font@latest/dist/Farsi-Digits/Sahel-FD.ttf') format('truetype');
font-weight: normal;
}
@font-face {
@sae13
sae13 / JobRunOnce.py
Created Jun 1, 2018
python-telegram-bot job run_once example
View JobRunOnce.py
from telegram.ext import Updater, Dispatcher, Job, CommandHandler
import logging
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def error(bot, update, error):
"""Log Errors caused by Updates."""
You can’t perform that action at this time.