Skip to content

Instantly share code, notes, and snippets.

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

Shrikanth shrikanthkr

🏠
Working from home
View GitHub Profile
@shrikanthkr
shrikanthkr / carrierwave-base64.md
Last active September 6, 2019 16:21
Saving base64 string with Carrierwave

In the controller action

image_file = change_img_params(params[:avatar]) #params[:avatar] - base64 string

def change_img_params(img)
begin
  Base64.decode64(img) #To check if thats a base64 string
  if img
    img = file_decode(img.split(',')[1],"some file name") #getting only the string leaving out the data/<format>

end

@shrikanthkr
shrikanthkr / reliace-net-card.md
Created April 11, 2014 16:44
How did I connect my reliance net card

#Prerequisite wvdial installed

##Create a rule for your net card lsusb

output may look like Bus 001 Device 023: ID 12d1:ffe9 Random Technologies Co., Ltd.

vendor - 12d1
product - ffe9
@shrikanthkr
shrikanthkr / grunt-aws-s3-sample.md
Last active August 29, 2015 14:00
Using grunt aws S3

#create package.json { "name": "my-project-name", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.3", "grunt-contrib-nodeunit": "~0.2.0", "grunt-contrib-uglify": "~0.2.2", "grunt-aws-s3": "~0.8.0"

###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
set mailserver smtp.gmail.com port 587 username "user@domain.com" password "password" using tlsv1 with timeout 30 seconds
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Observer Pattern</title>
</head>
<body>
<button id="addNewObserver">Add New Observer checkbox</button>
<input id="mainCheckbox" type="checkbox"/>
<div id="observersContainer"></div>
@shrikanthkr
shrikanthkr / gist:22b6b817fd2edb1b0e46
Last active August 29, 2015 14:03 — forked from cameronmccloud/gist:1258906
Socke IO testing
console.info("Socket.io chat test client");
io = require('socket.io-client');
var args = process.argv.slice(2);
Test = {};
Test.connections = parseInt(args[0]) || 100;
Test.completedProcesses = 0;
Test.failures = 0;
Test.pingServer = function(socket_n) {
var j = socket_n;
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
@shrikanthkr
shrikanthkr / monit-setup.md
Last active August 29, 2015 14:03
Monit RC with unicorn

#Set up monit

sudo apt-get install monit

###Config File

/etc/monit/monitrc //Monit runs as sudo- changing permissions cause monit not to start, so sticking with this now

#####reference Permissions

module MyApp
module Database
def connect(pool_size = nil, reap_time = nil)
return unless defined? ActiveRecord::Base
config = Rails.application.config.database_configuration[Rails.env]
config['reaping_frequency'] = reap_time || ENV['AR_DB_REAP_FREQ'] || 10 # seconds
config['pool'] = pool_size || ENV['AR_DB_POOL'] || 5
ActiveRecord::Base.establish_connection(config)
end