Skip to content

Instantly share code, notes, and snippets.

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

Amitav Roy amitavroy

🏠
Working from home
View GitHub Profile
@amitavroy
amitavroy / infinitescroll.js
Created March 25, 2013 11:44
This code is used to generate an infinite scroll. It appends the new data to the container. Need to work on providing an animation when the data is being fetched.
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
// calling the function to get the ajax data
loadMore();
}
});
function loadMore() {
$.ajax({
url: base_url + "/infscroll/get_inf_scroll_ajax",
@amitavroy
amitavroy / ga_event.js
Created March 27, 2013 14:18
This code shows how to add an event to a click or other user event.
$('.tab').click(function() {
$(this).show();
var eventCategory = jQuery(this).attr('data-category');
var eventAction = jQuery(this).attr('data-action');
var eventLabel = window.document.title;
_gaq.push(['_trackEvent', eventCategory, eventAction, eventLabel]);
});
@amitavroy
amitavroy / gist:5748254
Created June 10, 2013 12:03
Get all tweets of a specific hashtag
function getTweets($hash_tag) {
$url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ;
echo "<p>Connecting to <strong>$url</strong> ...</p>";
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$xml = curl_exec ($ch);
curl_close ($ch);
//If you want to see the response from Twitter, uncomment this next part out:
@amitavroy
amitavroy / gist:5748261
Created June 10, 2013 12:04
Adding odd even class
<div class="example-class<?php echo ($xyz++%2); ?>">
@amitavroy
amitavroy / html_default
Last active December 18, 2015 22:59
This is my default html file as a starting point
<!doctype html>
<html lang="en" ng-app="anim">
<head>
<meta charset="UTF-8">
<title>Test page</title>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
<script>
var anim = angular.module('anim', []);
anim.controller('MainCtrl', ['$scope', function ($scope) {
@amitavroy
amitavroy / gist:6507518
Created September 10, 2013 10:20
Calculate Page load time
<script>
var t0 = window.performance.now();
</script>
<script>
var t1 = window.performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
</script>
@amitavroy
amitavroy / .gitlab-ci.yml
Last active May 6, 2024 06:26
Continuous Integration with Gitlab
stages:
- test
# Variables: these have to match
# the .env.example credentials in your Laravel app
# use the default homestead/secret combination, since
# that database gets created in the edbizarro/gitlab-ci-pipeline-php:7.1
# docker image.
variables:
MYSQL_ROOT_PASSWORD: root
# Installing Apache, PHP and MySQL
sudo apt install -y apache2
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt install -y zip unzip git curl
sudo apt-get install -y php7.3-fpm php7.3-cli php7.3-gd php7.3-mysql \
php7.3-mbstring php7.3-xml php7.3-curl \
php7.3-bcmath php7.3-sqlite3 php7.3-zip
@amitavroy
amitavroy / LEMP Stack
Last active October 20, 2023 00:55
Setup for a new linux server with Nginx PHP and MySQL
# Basics
sudo apt-get update
sudo apt-get install -y git tmux vim curl wget zip unzip htop
# Nginx
sudo apt-get install -y nginx
# PHP
sudo add-apt-repository ppa:nginx/stable
sudo add-apt-repository -y ppa:ondrej/php
@amitavroy
amitavroy / PasswordHash.php
Created August 6, 2018 06:09
Wordpress user password check on other system
<?php
/**
* Portable PHP password hashing framework.
* @package phpass
* @since 2.5.0
* @version 0.3 / WordPress
* @link http://www.openwall.com/phpass/
*/
#