Skip to content

Instantly share code, notes, and snippets.

View bibiboot's full-sized avatar

Bibiboot bibiboot

View GitHub Profile
@bibiboot
bibiboot / pycurses.py
Created August 6, 2012 07:01
Hello world python curses
import curses
SCREEN_WIDTH, SCREEN_HEIGHT = 100, 100
class curses_screen:
def __enter__(self):
"""Initialize"""
self.stdscr = curses.initscr()
curses.cbreak()
curses.noecho()
@bibiboot
bibiboot / pycurses.py
Created August 6, 2012 07:28
Running the python curses
with curses_screen() as stdscr:
"""
Execution of the curses begins here.
"""
# Retrieve the size of the terminal currently open.
SCREEN_HEIGHT, SCREEN_WIDTH = stdscr.getmaxyx()
# Create the pad
mypad = curses.newpad(SCREEN_HEIGHT, SCREEN_WIDTH)
# Refresh the pad
@bibiboot
bibiboot / strptime-python.py
Created August 10, 2012 09:12
Strptime-python-hack
import datetime
import thread
import sys
"""
Pass either 'Replicate' or 'Fix' as the
parameter while running the file.
"""
def print_time( threadName, delay):
@bibiboot
bibiboot / wordnik-dump.py
Created October 8, 2012 05:37
Dump of wordnik
"""
Dumps html from http://www.wordnik.com/ for the words mentioned in the
file 'only_words'. An appendix html is also created named as 'words.html',
which contains the link to the dumped htmls of corresponding words.
"""
import os
for line in [ line.rstrip('\n') for line in open('only_words') ]:
fw = open('words.html', 'a')
@bibiboot
bibiboot / watch.sh
Created October 19, 2012 07:28
Script watch
#!/bin/bash
# find if Apache (httpd) running or not
service_list=('application_errormonitor.py' 'controller_errormonitor.py')
COUNTER=0
for service in ${service_list[@]}
do
echo "----------------"
if ps ax | grep -v grep | grep $service > /dev/null; then
echo "$service service running, everything is fine"
@bibiboot
bibiboot / restart.py
Created October 31, 2012 05:51
Process timeout and status check
def restart(timeout=5):
"""
Script polls the process checking
for the status of the process.
"""
status, success = "Restart successfull....", True
start = datetime.now()
proc = subprocess.Popen(CMD, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Polling to have process timeout
@bibiboot
bibiboot / doubt_thread_exit
Created September 10, 2013 00:12
Doubt regarding the pthread_exit
int main(int argc, char *argv[])
{
int i=1;
void *output;
pthread_t thread;
int status = pthread_create(&thread,
NULL,
server,
(void*)i);
#include <stdio.h>
#include <time.h>
#include <signal.h>
int handler();
void show_status();
int long_running_procedure( struct timespec time_sleep, struct timespec time_rem);
int status = 0;
@bibiboot
bibiboot / Mount external file system
Created January 8, 2015 04:28
Mount an external files system on mnt
>> /usr/testbed/bin/mkextrafs /mnt
@bibiboot
bibiboot / Compile kernel
Last active August 29, 2015 14:13
Compile a kernel
# Download the kernel
>> cd /mnt/local
>> wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.tar.gz
>> sudo apt-get install libncurses5-dev libncurses5
>> tar -xvf linux-3.2.63.tar.gz
>> cd linux-3.2.63
>> make menuconfig
# Build the kernel
>> make && make modules && make modules_install && make install
>> sudo reboot