Skip to content

Instantly share code, notes, and snippets.

View swarad07's full-sized avatar
💻
Working from home

Swarad swarad07

💻
Working from home
View GitHub Profile
@swarad07
swarad07 / PHP 5.2.17
Last active October 20, 2021 07:25
Script to compile php 5.2.17 from source, can be used with Vagrant
echo "### PROVISIONIN PHP 5.2.17..."
if [ "$(whoami)" != "root" ]
then
sudo su -s "$0"
exit
fi
# Add PostgreSQL Apt Repository (provides postgresql-server-dev-9.4)
echo "### Installing wget and other dependencies"
apt-get install -y wget
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
#!/bin/bash
# Based on https://gist.github.com/ManuelTS/935155f423374e950566d05d1448038d
set -eo pipefail
# This script installs PhantomJS and Wraith along with its dependencies.
npm install -g casperjs
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
@swarad07
swarad07 / wraith-setup.sh
Created May 30, 2018 10:37
wraith setup
$> wraith setup
create configs
create configs/capture.yaml
create configs/history.yaml
create configs/spider.yaml
create javascript
create javascript/cookies_and_headers--casper.js
create javascript/cookies_and_headers--phantom.js
create javascript/disable_javascript--casper.js
create javascript/disable_javascript--phantom.js
// ######################################################
// This is an example module provided by Wraith.
// Feel free to amend for your own requirements.
// ######################################################
module.exports = function (phantom, ready) {
// make Wraith wait a bit longer before taking the screenshot
setTimeout(ready, 10000); // you MUST call the ready() callback for Wraith to continue
}
// ######################################################
// This is an example module provided by Wraith.
// Feel free to amend for your own requirements.
// ######################################################
module.exports = function (phantom, ready) {
// make Wraith wait a bit longer before taking the screenshot
setTimeout(ready, 10000); // you MUST call the ready() callback for Wraith to continue
}
- run:
name: Run wraith
command: 01-wraith-run
- store_artifacts:
path: ./wraith/shots
@swarad07
swarad07 / unused-variables.sh
Created October 31, 2018 03:06
Find unused sass variables. Inspired from https://gist.github.com/badsyntax/6193491
#!/usr/bin/env bash
#
# Approach:
# 1. Find variable declaration in the form of "$my-var: anyvalue"
# 2. Loop through found variables and find occurrences of each variable in all sass files
# 3. Filter out vars that occurred only once
# Usage:
# Create a file (e.g. unused-variables.sh) having the below code, place it outside your sass folder.
# Run chmod +x ./unused-variables.sh to give execute permission to your script.
@swarad07
swarad07 / layout-debug.js
Last active May 6, 2020 17:30
Layout highlighter
/**
* Open browser console and add paste the below line.
* Outline will be added to all the elements.
*
* Credit for original idea: https://github.com/saki007ster
*/
$$('*').map(A=>A.style.outline=`1px solid hsl(${(A+A).length*9},99%,50%`);
@swarad07
swarad07 / directive.js
Created February 5, 2019 11:25
Directive.js from demo page https://www.cssscript.com/demo/touch-enabled-image-zoom-plugin-javascript/ the github repo points to a new version which doesnt work in Chrome mobile on some devices.
// @codingStandardsIgnoreStart
"use strict";
zoom();
function zoom(classNames, settings) {
/**
* IE 11 Compatiblity fix.
*
* IE 11 doesnt support ES6 standard so the function defination line,
* function zoom(classNames = {}, settings = {}) {
@swarad07
swarad07 / wraith-run.sh
Created February 12, 2019 08:55
wraith-run.sh
#!/bin/bash
set -eo pipefail
# This script configures wraith and runs wraith.
# Fetching Pantheon URL with env:view command.
PANTHEON_ENVIRONMENT=$(terminus env:view --print "$TERMINUS_SITE.$TERMINUS_ENV")
# Pantheon adds a trailing slash, removing it so it works correctly with sed.
PANTHEON_ENVIRONMENT=${PANTHEON_ENVIRONMENT::-1}