Skip to content

Instantly share code, notes, and snippets.

View SabujXi's full-sized avatar
:octocat:
Available for Hire

Md. Sabuj Sarker SabujXi

:octocat:
Available for Hire
View GitHub Profile
@SabujXi
SabujXi / remove-all-sent-friend-requests-at-once.js
Created May 10, 2018 13:10
Remove all sent friend request from facebook at once. Use Google Chrome UA on desktop Firefox or Chrome browser. Go to sent requests page and paste the script in web console. Hit enter to kick in the show -_-
var es = document.querySelectorAll('button[value="Undo"]');
function doo(){
for (var ei=0; ei < es.length; ei++){
var e = es[ei];
e.click();
var btnoks = document.querySelectorAll('button[value="Ok"]')
if (btnoks.length > 0){
btnoks[0].click();
}
if (ei == es.length - 1){
test
@SabujXi
SabujXi / refresh_this_page.js
Last active July 2, 2017 18:12
The simplest js code to be used with web console/dev tools to keep the page refreshed every few minutes
(function (interval_min, url){
// Constants
var CONTAINER_TOP_OFFSET = 30;
var CONTAINER_MARGIN = 20,
CONTAINER_PADDING = 10,
BUTTON_CONTAINER_HEIGHT = 30;
// Due to cross origin policy some site will not allow iframing - so we will create an iframe inside the same page.
var body_info = {width: screen.availWidth, height: screen.availHeight }; // document.body.getBoundingClientRect();//document.getElementsByTagName("body")[0].getBoundingClientRect();
var body_width = body_info.width - (CONTAINER_MARGIN * 2) - (CONTAINER_PADDING * 2) - 20,
body_height = body_info.height - (CONTAINER_MARGIN * 2) - (CONTAINER_PADDING * 2) - CONTAINER_TOP_OFFSET - BUTTON_CONTAINER_HEIGHT - 20 - 50;
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-91-b6f524c4a765> in <module>()
----> 1 class Accountant(metaclass=CompanyMETA):
2 name = ""
3 salary = 150000.00
4
<ipython-input-90-01e64576f9dc> in __new__(cls, name, parents, dct)
11 else:
class Accountant(metaclass=CompanyMETA):
name = ""
salary = 150000.00
class Developer(metaclass=CompanyMETA):
name = ""
salary = 250000
class CompanyMETA(type):
@classmethod
def __prepare__(cls, name, parents, **kwargs):
return {}
def __new__(cls, name, parents, dct):
for attr, value in dct.items():
if not attr.startswith("__"):
if callable(value):
if not attr.startswith("c_"):
raise TypeError("You cannot define a method that starts with something other than 'c_'")
class MyMeta(type):
@classmethod
def __prepare__(cls, name, parents, **kwargs):
print("I am __prepare__ and I am being called. I must return a dictionary or dictionary like object to be used as namespace for the class")
return {}
def __new__(cls, name, parents, dct):
print("I am a class and I am beign created by MyMeta.__new__")
return super(MyMeta, cls).__new__(cls, name, parents, dct)
class MyMeta(type):
def __new__(cls, name, parents, dct):
print("I am a class and I am beign created by MyMeta.__new__")
return super(MyMeta, cls).__new__(cls, name, parents, dct)
def __init__(cls, name, parents, dct):
print("Hey I am initiating the class after creation with an useless variable")
cls.useless_var = "Useless string"
class MyMeta(type):
def __new__(cls, name, parents, dct):
print("I am a class and I am beign created by MyMeta.__new__")
return super(MyMeta, cls).__new__(cls, name, parents, dct)
class MyClass(metaclass=MyMeta):
pass