Skip to content

Instantly share code, notes, and snippets.

View ravikiranj's full-sized avatar

Ravikiran Janardhana ravikiranj

View GitHub Profile
@ravikiranj
ravikiranj / cors.js
Created October 14, 2014 02:29
CORS Javascript
window.onerror = function(errorMsg, file, lineNo, colNo, errStack) {
"use strict";
var msg = errorMsg ? errorMsg : "null"
, stack = errStack ? errStack : "null, only Chrome/Chromium/Firefox based browsers support errorStack"
, errFile = file ? file : "null"
, errLineNo = lineNo ? lineNo : "null"
, msgElem = document.getElementById("MSG")
, stackElem = document.getElementById("STACK")
, fileElem = document.getElementById("FILE")
, lineElem = document.getElementById("LINE_NO")
@ravikiranj
ravikiranj / cors-test.html
Created October 14, 2014 02:26
CORS Test HTML
<!DOCTYPE html>
<html>
<head>
<title>CORS Example</title>
<style type="text/css">
div {
border: 1px solid #C0C0C0;
padding: 10px;
border-radius: 10px;
margin: 5px;
@ravikiranj
ravikiranj / twitter_search_demo.py
Last active August 29, 2015 13:55
Twitter Search Demo
get_twitter_data.py
===================
#!/usr/bin/env python
import argparse
import urllib
import urllib2
import json
import os
import oauth2
@ravikiranj
ravikiranj / xrandr-4.py
Last active November 23, 2017 18:28
brightness control command line tool
#!/usr/bin/env python
from gi.repository import Gtk
import subprocess
class BrightnessScale:
def __init__(self):
# get active monitor and current brightness
self.monitor = self.getActiveMonitor()
self.currB = self.getCurrentBrightness()
@ravikiranj
ravikiranj / xrandr-3.sh
Last active May 14, 2018 18:34
brightness command line tool using xrandr
function brightness(){
if [ $# -gt 0 ]; then
# set brightnessValue
brightnessValue=$1
# get activeDisplay
activeDisplay=`xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1`
# change brightness if $activeDisplay is not empty
if [ "$activeDisplay" != "" ]; then
xrandr --output $activeDisplay --brightness $brightnessValue
else
@ravikiranj
ravikiranj / xrandr-2
Last active December 19, 2015 23:19
xrandr - extract active display name
[ravikirn@rk-dell-xps ~]# xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1
LVDS1
@ravikiranj
ravikiranj / xrandr-1
Created July 18, 2013 23:47
xrandr - query the current display state of the system
[ravikirn@rk-dell-xps ~]# xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 32767 x 32767
LVDS1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
1920x1080 60.0*+ 59.9
1680x1050 60.0 59.9
1600x1024 60.2
1400x1050 60.0
1280x1024 60.0
1440x900 59.9
1280x960 60.0
@ravikiranj
ravikiranj / svmMatlabSparseMatrix.m
Created December 8, 2012 17:18
SVM Matlab - Large Sparse Matrices (20000 feature vector size)
clc;clear;
% start time
tic;
%feature vector size
featSize = 20000;
% training data
N = 300;
neg = randi([1, N], int16(N/3), 1);
@ravikiranj
ravikiranj / tw-20.py
Created June 2, 2012 19:56
Get Tweets for a keyword
import urllib
import urllib2
import json
#start getTwitterData
def getData(keyword):
url = 'http://search.twitter.com/search.json'
data = {'q': keyword, 'lang': 'en', 'result_type': 'recent'}
params = urllib.urlencode(data)
try:
@ravikiranj
ravikiranj / tw-19.php
Created June 2, 2012 19:52
API Endpoint for Tweet Search
#Search for 'keyword'
http://search.twitter.com/search.json?q=keyword&lang=en&result_type=recent
#Search for 'keyword' between 20120601 and 20120602
http://search.twitter.com/search.json?q=keyword&lang=en&result_type=recent&since=20120601&until=20120602