Skip to content

Instantly share code, notes, and snippets.

View tejastank's full-sized avatar

Tejas Tank tejastank

  • India
  • 23:04 (UTC +05:30)
View GitHub Profile
@tejastank
tejastank / raspberrypi_gpio_tejastank
Created March 16, 2014 08:37
raspberryPi_GIP_installation
If you're like me, you bought your RPi to "control things" using the I/O pins on the RPi. Using Python and the RPi GPIO library, you can do just that. Python should already be installed on your RPi, and it takes just a minute to install the GPIO library:
Open the terminal on your RPi. Double-click the icon on the desktop named LXTerminal
Type the following command to download the GPIO library as a tarball:
wget http://raspberry-gpio-python.googlecode.com/files/RPi.GPIO-0.4.1a.tar.gz
Unzip the tarball:
tar zxvf RPi.GPIO-0.4.1a.tar.gz
@tejastank
tejastank / raspberry_Pi_gipo_python-tejastank.py
Created March 16, 2014 08:38
raspberrypi_gpio_simplest_code
import RPi.GPIO as GPIO ## Import GPIO Library
GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering
GPIO.setup(7, GPIO.OUT) ## Setup GPIO pin 7 to OUT
GPIO.output(7, True) ## Turn on GPIO pin 7
<script type="text/javascript" language="javascript">// <![CDATA[
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'inline';
}
else {
document.getElementById(shID+'-show').style.display = 'block';
document.getElementById(shID).style.display = 'none';

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@tejastank
tejastank / thresold_monitor_email.sh
Last active August 29, 2015 14:02
Shell Script thresold email notification. https://twitter.com/snippetbucket
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 90 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep%" you@somewhere.com
fi
@tejastank
tejastank / header.rml
Created June 16, 2014 16:05
openerp / odoo custom header, Author: twitter.com/snippetbucket
<?xml version="1.0"?>
<header>
<pageTemplate>
<frame id="first" x1="1.3cm" y1="3.0cm" height="150.00cm" width="19.0cm"/>
<stylesheet>
<!-- Set here the default font to use for all <para> tags -->
<paraStyle name="Normal" fontName="DejaVu Sans"/>
<paraStyle name="main_footer" fontSize="8.0" alignment="CENTER"/>
<paraStyle name="main_header" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
#!/bin/sh
# Install OpenERP 7 on Digital Ocean
# Fernando Altuzar
# Modified script from Carlos E. Fonseca Zorrilla & Mario Gielissen
# First: Create a Droplet with CentOS 32 bits
# Then:
yum -y install wget unzip
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-6.noarch.rpm
@tejastank
tejastank / gist:658d8159868b85563a99
Last active August 29, 2015 14:04
1 Cent to Paisa.
1usd = 100 cents
1usd = 60.096 Rupee # Rate at July 28, 2014.
1 Rupee = 100 paise
1.5 cent = ? rupee
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
// PDO Connection to MySQL
$conn = new PDO('mysql:host=localhost;dbname=yourdbname', 'username', 'password');
// PDO Connection to PostgreSQL
$conn = new PDO('pgsql:host=localhost;dbname=yourdbname', 'username', 'password');
// A quick Select Query with For Loop
foreach ($conn->query("SELECT * FROM profile") as $row)
echo $row['fullname'];