Skip to content

Instantly share code, notes, and snippets.

View eteamin's full-sized avatar
🌴
On vacation

Amin Etesamian eteamin

🌴
On vacation
View GitHub Profile
@meyt
meyt / extract_hashtags.py
Last active July 25, 2018 08:25
Extract hashtags from string (python 3.x)
import re
import unittest
def extract_tags(text: str) -> list:
return re.compile(r"(?:^|\W)[##](?!\d\d)(?!\d$)(\w+)", re.UNICODE).findall(text)
class ExtractTagsTestCase(unittest.TestCase):
@ParsaHarooni
ParsaHarooni / channel.js
Created January 8, 2018 11:39
Get telegram channel member count.
// npm install request
// npm install cheerio
const request = require("request");
const cheerio = require("cheerio")
function getMembersCount(channel) {
return new Promise((resolve, reject) => {
request(`https://t.me/${channel}/?pagehidden=false`, (error, resp, body) => {
const data = cheerio.load(body, {normalizeWhitespace:true});
@levynir
levynir / RotatingView.js
Last active January 19, 2021 09:52
React Native Rotating Component
/**
* Created by nirlevy on 02/07/2017.
* MIT Licence
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Animated, Easing } from 'react-native';
export class RotatingView extends Component {
state = {
# PYANDROID
# VERSION 1.1 ALPHA
# USES (v1.0):
# android_version(e*)
# sdk_version(e)
# android_name(e)
# processor_machine()
# ram_total(type_)
# directory_size(directory)
@cahna
cahna / parse_ps_aux.py
Last active September 27, 2023 22:39
Parse the output of `ps aux` into a list of dictionaries representing the parsed process information from each row of the output.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pprint
import subprocess
def get_processes():
"""
Parse the output of `ps aux` into a list of dictionaries representing the parsed
@sairion
sairion / Instagram shared data.js
Created August 28, 2016 10:35
Get Instagram shared data via fetching HTML (i.e. location data)
let __DEBUG_HTML = '';
function fetchLoc(locID){
return fetch(`https://www.instagram.com/explore/locations/${locID}/`)
.then(res => res.text())
.then(txt => {
__DEBUG_HTML = txt;
const doc = parseInstgramExplorePage(txt);
const sharedData = extractSharedData(doc);
const locData = extractLocationData(sharedData);
@pylover
pylover / inspections.txt
Last active November 2, 2024 22:16 — forked from ar45/inspections.txt
PyCharm inspections
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'
# noinspection PyPep8
# noinspection PyPep8Naming
# noinspection PyTypeChecker
# noinspection PyAbstractClass
# noinspection PyArgumentEqualDefault
# noinspection PyArgumentList
# noinspection PyAssignmentToLoopOrWithParameter
# noinspection PyAttributeOutsideInit
@shihyuan
shihyuan / ipcam.py
Last active November 25, 2022 18:54
Stream Video with OpenCV in Python from an Android running IP Webcam
# Stream Video with OpenCV from an Android running IP Webcam (https://play.google.com/store/apps/details?id=com.pas.webcam)
# Code Adopted from http://stackoverflow.com/questions/21702477/how-to-parse-mjpeg-http-stream-from-ip-camera
import cv2
import urllib2
import numpy as np
import sys
host = "192.168.0.220:8080"
if len(sys.argv)>1:
@rogererens
rogererens / client_kivy.py
Created October 2, 2014 21:54
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):
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()