Skip to content

Instantly share code, notes, and snippets.

View endeepak's full-sized avatar

Deepak Narayana Rao endeepak

View GitHub Profile
// Motor Code Adopted From: http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/?ALLSTEPS
int motor_left[] = {2, 3};
int motor_right[] = {7, 8};
void setup() {
for(int i = 0; i < 2; i++){
pinMode(motor_left[i], OUTPUT);
pinMode(motor_right[i], OUTPUT);
}
}
// Ping Code Adopted From: https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home#!single-pin-sketch
#include <NewPing.h>
#define PING_PIN 12 // Arduino pin tied to both trigger and echo pins on the ultrasonic sensor.
#define PING_MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(PING_PIN, PING_PIN, PING_MAX_DISTANCE); // NewPing setup of pin and maximum distance.
void setup() {
Serial.begin(9600);
CREATE DATABASE oracle;
\c oracle;
CREATE TABLE matrix("the 1" varchar);
INSERT INTO matrix VALUES('Neo');
SELECT "the 1" FROM matrix;
# Delete all indices
curl -XDELETE localhost:9200/*
@endeepak
endeepak / xvfb
Last active August 29, 2015 14:10 — forked from iafonov/gist:1113433
#!/bin/sh
unset DISPLAY
if [ ! -f /tmp/.X99-lock ]; then
Xvfb :99 -ac &
fi
export DISPLAY=:99
bundle install --path ../bundle --quiet --without development production &&
@endeepak
endeepak / minglify-trello.js
Created June 7, 2014 18:59
Show card number, number of cards in trello
(function(){
var update = function() {
$('.card-short-id').removeClass('hide').css('font-weight',700);
$('.list-header-num-cards').removeClass('hide').css('font-weight',700);
};
$(document).ready(function() {
update();
setInterval(update, 5000);
});
@endeepak
endeepak / debug_angular_ui_router.js
Last active February 21, 2021 19:28
Debugging angula ui router
// Credits: Adam's answer in http://stackoverflow.com/a/20786262/69362
// Paste this in browser's console
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeError - fired when an error occurs during transition.');
@endeepak
endeepak / $q_all.js
Last active August 29, 2015 13:56
Angular: $q's short methods which might help you delete some code
//Creating promise which resolves after all promises are resolved
var deferrable = $q.defer();
var promises = [];
promises.push(fooPromise);
promises.push(barPromise);
$q.all(promises).then(function(){
deferrable.resolve();
})
return deferrable.promise;
angular.module('overlay', [])
.factory('overlay', function () {
var enabled = true;
var show = function(){
if(enabled)
$('#overlay').show();
}
var hide = function(){
// Basics
"foo" // string
'foo' // string
var foo = {} // new object
[1, 2, "foo", "bar"] // new array
var foo = {
name: 'Foo',
Greet: function(otherName){
console.log("Hello I am " + this);
console.log("Hello " + otherName + " my name is " + this.name);