Skip to content

Instantly share code, notes, and snippets.

View gkarthik's full-sized avatar
👽
I'm an imposter

Karthik gkarthik

👽
I'm an imposter
View GitHub Profile
#! /bin/sh
### BEGIN INIT INFO
# Provides: ghost
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ghost Blogging Platform
# Description: Ghost: Just a blogging platform
### END INIT INFO
@gkarthik
gkarthik / InsertJson
Created June 21, 2014 00:02
Insert test into postgressql as JSON
package checkPostGre;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.postgresql.util.PGobject;
package checkPostGre;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
@gkarthik
gkarthik / gist:73de2a650130df8168b4
Last active August 29, 2015 14:05
Pseudo code - CSV or TSV
read file into line
while(line){
if(prevline != null && line.length > 0 && line.chatAt(0)!="#"){ // Check for comment etc
tab = line.split("\t");
comma = line.split(",");
if(tab <1 && comma < 1 && prevline.split(",") <1 && prevline.split("\t") <1 ){
return "invalid";
}
if(prevline.split(",").length == comma.length && comma.length >1 && comma.length > tab.length){
@gkarthik
gkarthik / simulate.py
Created November 28, 2014 02:46
Biased vs UnBiased Dice
from random import randrange
import matplotlib.pyplot as PLT
biasedDiceDist = [1,2,3,4,4,4,5,6]
unbiasedDiceDist= [1,2,3,4,5,6]
board = [0] * 40
rollSum = 0
fig = PLT.figure()
def roll(dist):
spi <- hardware.spiEBCA
spi.configure(CLOCK_IDLE_LOW,10000)
acc <- hardware.pinT
cs <- hardware.pinS
// BMA280 Register Values
const BGW_CHIPID = 0x00;// chip ID should be FB
const INT_STATUS_1 = 0x0A;// contains interrupt status flags
const FIFO_STATUS = 0x0E;// contains nr of samples in FIFO
const PMU_RANGE = 0x0F;// selects g-range
/home/gk/Envs/flask/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/home/gk/Envs/flask/bin/python and that PATH is
set properly.
/home/gk/Envs/flask/bin/python: No module named virtualenvwrapper
/home/gk/Envs/flask/bin/python: No module named virtualenvwrapper
Traceback (most recent call last):
@gkarthik
gkarthik / Rotation.java
Last active April 5, 2016 19:05
Android Camera Rotation
public int getCameraRotation(Activity activity, int cameraId){
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay()
.getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0: degrees = 0; break;
case Surface.ROTATION_90: degrees = 90; break;
@gkarthik
gkarthik / angular-compile-dynamic-html.md
Created August 9, 2016 21:47 — forked from umidjons/angular-compile-dynamic-html.md
Compile dynamic template from outside of angular.

Compile dynamic template from outside of angular

I want to load dynamic HTML content via AJAX, then compile it, because it contains angular directives.

<!DOCTYPE html>
<html ng-app="app">
<head>
@gkarthik
gkarthik / bamfilter_oneliners.md
Created August 31, 2016 00:16 — forked from davfre/bamfilter_oneliners.md
SAM and BAM filtering oneliners