Skip to content

Instantly share code, notes, and snippets.

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

Anil anil826

🏠
Working from home
  • New Delhi , India
View GitHub Profile
@anil826
anil826 / piwik.rb
Created December 1, 2015 05:39
piwi database using ruby in rails
require 'mysql'
module Piwik
#--------------query for piwik database for getting token of user-----------
def piwik_tokens
!connection_piwik.nil? ? @rs = connection_piwik.query('select login, token_auth from enbake_piwik_user;') : "#{["Connect-Piwik-Sever"]}"
!@rs.nil? ? result : ["Connect-Piwik-Sever"]
end
#--------------------query for site_ids for clients dashboard----------------
def piwik_site_ids
@anil826
anil826 / show.js
Created December 1, 2015 05:52
showing uploaded file in iframe
$(document).on("input",".upload", function(){
var src = $(this).val();
src = src.replace("watch?v=", "v/");
src = src.replace("video/", "embed/video/");
var abc="<iframe src='my_source' width='452' height='345' scrolling='no' frameborder='no' target='_top' allowFullScreen></iframe>".replace(/my_source/g,src);
if (src.match(/(youtube|youtu|vimeo|veoh|dailymotion|kickstarter|metacafe)\.(com|be)\/((watch\?v=([-\w]+))|(video\/([-\w]+))|(projects\/([-\w]+)\/([-\w]+))|([-\w]+))/)) {
$(this).next('#thumbs').empty().append(abc);
}
else if( src.match(/^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.mp4|.MP4|.avi|.AVI|.3gp|.3GP)$/)) {
$(this).next('#thumbs').empty().append(abc);
@anil826
anil826 / faye.rb
Created December 1, 2015 07:00
sending file using faye server
var sendMessage = function(file) {
client.publish(channel, { file: file });
}
var fr = new FileReader();
fr.onload = function(event) {
sendMessage(event.target.result);
};
@anil826
anil826 / app.js
Last active December 16, 2015 09:25
Oauth for angularJs using satellizer
(function () {
'use strict';
var app = angular.module('app', ['ngRoute', 'ngStorage', 'ui.bootstrap.modal', 'autocomplete', 'timer', 'satellizer']);
app.config(function ($authProvider) {
$authProvider.google({
//clientId: 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com' //development
clientId: 'xcccccccccccccccccxxxxxx.apps.googleusercontent.com' //production
});
@anil826
anil826 / registration.htm
Created December 23, 2015 04:21
Angular registration page
<div class="container" ng-controller="adminUserCtrl as employee" style="margin-top:30px">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title"><strong>Add Employee </strong></h3>
<div style="float:right; font-size: 80%; position: relative; top:-10px"><a href="#">All employee</a>
</div>
</div>
<div class="panel-body">
@anil826
anil826 / crontab.txt
Created January 3, 2016 10:17
cronjob commands
crontab -l #list all cronjob using this command
crontab -r #To remove all cronjob which are listed.
crontab -e #which will allow you to edit the crontab file, deleting or commenting out the offending line.
@anil826
anil826 / help.txt
Last active February 18, 2016 19:27
angularjs-bootstrap date-picker problem
#if you have problem relate picking date on pop-up modal of bootstrap in AngularJs aplication.
#Then it mean you have Time-zone problem to solve this proble for all time-zone just add a custom time zone to your time zone
then it will work same for every time zone.
i.e:
var date = '12/02/2016' , + " 12:00:00 UTC"
@anil826
anil826 / ruby_shell.rb
Last active March 28, 2016 05:25
Shell scripting in ruby
#!/usr/bin/ruby -w
#system('ls -la') #=> outputs the output of that command
#system('skype') #open skype using system command.
#http://www.dreamsyssoft.com/ruby-scripting-tutorial/loops-tutorial.php
require 'optparse'
options = {:name => nil, :age => nil}
@anil826
anil826 / upwork_tracker_free_time.rb
Last active April 1, 2016 06:55
Simple Script for switching terminal and tabs for UPWORK guys ;)
#!/usr/bin/env python
#To run this script in terminal first to install this dependancy: sudo apt-get install xdotool
#To make it excutable GoTo the file directory and run the command: chmod u+x upwork_tracker_free_time.rb
#Now you just need to run this file using form termial :~ ./upwork_tracker_free_time.rb
#Note: You need to specifiy every on which work space you want to swicth tab currently In code I am only swithching termial
#But you can also switch browser tab or sublim tabs subprocess.call("xdotool key ctrl+Tab" ,shell=True)
#Enjoy :)
import subprocess
import time
subprocess.call("xdotool key ctrl+alt+Up" ,shell=True)
@anil826
anil826 / git.txt
Created May 4, 2016 11:43
remove from git tracking list if you accidentally added nodes project file
git rm --cached -r app/bower_components/*