Skip to main content

Posts

Showing posts with the label python

Automatically Open DevTools when newtab open in Browser

One of cool topic which is told by my friend, He is web developer we want devtools to open whenever new tab get open so we searched the internet to automatically open devtools there are plenty but none didn't work for me So I decided to write by own using some browser addon i have Here the procedure is for MAC Tools:       [+] GreaseMonkey -> available for firefox       [+] TamperMonkey -> incase of chrome Working: I achieved this using Client-Server Model Client : Browser using the GreaseMonkey/TamperMonkey send the request to the Server Server: If any request received from client, It send the KeyStroke option+command+c ( differs for Operating system  )   so the devtools will open Program: Client Side ======== // ==UserScript== // @name Unnamed Script 977967 // @version 1 // @grant none // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js // @include * // ==/UserScript== ...

Lazy argument passing

passing many argument is time consuming and boring so to make it easy i created a python script  Dependencies        xdotool for sending arguments to program        zenity for dialog box generation (one of the cool program check out more in https://www.howtogeek.com/107537/how-to-make-simple-graphical-shell-scripts-with-zenity-on-linux/ ) import os import time #os . system( "zenity --title 'Lazy arguments' --entry --text 'Enter the arguments' > /tmp/lazy" ) os . system( "zenity --editable --title 'Lazy arguments' --text-info --text 'Enter the arguments' --height=500 --width=501 > /tmp/lazy" ) time . sleep(1) os . system( "xdotool type --file /tmp/lazy" ) working  pretty easy script  1. get the arguments to be passed using zenity  2. send it using xdotools

Python script for Automatic compile and Run c program

  # inorder to make the program to work you need # xdotool # pyperclip # python ( ofcourse ) # important it is done for linux based system so windows user hit  " powershell " that will give u necessary power import os import time import pyperclip #library for accessing clipboard #creating a time delay for 2 seconds time . sleep (2) #sending the key stroke ctrl+c i.e copy using xdotool os. system ( "xdotool key --delay 13 ctrl+c" ) #some predefined stmt x = "#include<stdio.h> \n int main(){" #combine above stmt with what we copied x+=pyperclip.paste() #last touch to c code x+= "return 0;}" #creating 1 sec delay time . sleep (1) # i prefare storing files in tmp directory f= open ( "/tmp/code.c" , "w" ) #write the data to file and length contains no of bytes  return if u want use it or leave it length = f. write (x) #close the file f. close () ## Here is the actual magic happens open a...

Tired of reading - Little python script to speak the selected word

python code here import  os   import  time   import  pyperclip time . sleep(2) os . system( "xdotool key --delay 13 ctrl+c" ) x = pyperclip . paste () f = open( "/tmp/temp" ,  "w" ) length   =  f . write(x) f . close () time . sleep(1) os . system( "espeak -f /tmp/temp" )   dependencies:      pyperclip  - python library to get text from clipboard      epseak       - convert text to speak (linux)       xdotool     - send key strokes working      Select the text to speak       Then press a key stroke ( assign th python script to key stroke )       The data selected is copied to clipboard and using python get the clipboard data using pyperclip and store it in temp f...