Skip to content

Instantly share code, notes, and snippets.

View prahladyeri's full-sized avatar
🏠
Working from home

Prahlad Yeri prahladyeri

🏠
Working from home
View GitHub Profile
@prahladyeri
prahladyeri / handy.js
Created June 15, 2015 17:49
Custom javascript library for doing misc things.
/**
* @author Prahlad Yeri
* @copyright MIT license
* @brief Custom javascript library for doing misc things.
* @date 28-01-2015
*/
/**
* @brief Constructor pattern for menu item.
* @param text Text to display on menu. "-" for divider.
#!/usr/bin/python
# author: Prahlad Yeri
# description: Script to track bandwidth consumption and put in database. Place this in /etc/NetworkManager/dispatcher.d/
import subprocess, os, datetime, sys
def execute(command):
try:
p=subprocess.Popen(command, shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p.wait()
@prahladyeri
prahladyeri / Product.java
Last active December 17, 2015 09:04
Rockstar Java Dev series: Using Lambda expressions
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
interface ProductFilter
{
public boolean run(Product p);
}
public class Product
<?php
//Fetching the latest value of BSE-Sensex in just 9 lines of PHP code:
$data = http_build_query(array("client"=>"ig", "q" => 'BSE:SENSEX'));
$url = "http://finance.google.com/finance/info?";
$ch = curl_init();
$curlConfig = array( CURLOPT_URL => $url.$data, CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
@prahladyeri
prahladyeri / utils.js
Created December 24, 2016 14:14
A bunch of basic javascript utilities and helper functions
/**
* A bunch of basic javascript utilities and helper functions.
* Depends on jQuery, Bootstrap.
*
* @author Prahlad Yeri (prahladyeri@yahoo.com)
* */
function retrieveURL(filename) {
var scripts = document.getElementsByTagName('script');
if (scripts && scripts.length > 0) {
@prahladyeri
prahladyeri / Utils.php
Last active December 30, 2016 18:36
An open source utility module for CodeIgniter Framework
<?php
/**
* Common Utilities Library
*
* An open source library module for CodeIgniter Framework
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2016, Prahlad Yeri
*
@prahladyeri
prahladyeri / disqus_parse.php
Created September 7, 2017 08:53
Tool to parse disqus comments xml file
<?php
/*
* Tool to parse disqus comments xml file.
*
* @author Prahlad Yeri<prahladyeri@yahoo.com>
* @date 2017-09-06
* */
function find_url($root, $thid) {
foreach($root->thread as $thread) {
@prahladyeri
prahladyeri / batteryboy
Created September 10, 2017 03:50
A small script to check laptop battery life on linux
#!/usr/bin/env python3
import sys
import subprocess, os
from time import sleep, time
__author__ = "Prahlad Yeri"
__version__ = "1.0.7"
def execute_shell(command, error=''):
return execute(command, wait=True, shellexec=True, errorstring=error)
@prahladyeri
prahladyeri / tree
Created September 21, 2017 12:53
Python-3 implementation of the tree linux command
#! /usr/bin/env python3
__author__ = "Prahlad Yeri"
__license__ = "MIT"
__version__ = "0.0.1"
import os, sys
def print_tree(dirname, pref = ""):
for item in os.listdir(dirname):
@prahladyeri
prahladyeri / split_tweet.py
Created September 22, 2017 03:37
Python script to split your long tweet into small chunks of 140 characters limit imposed by Twitter
#!/usr/bin/env python3
import os, sys
max_length = 140
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
if __name__ == "__main__":