Skip to content

Instantly share code, notes, and snippets.

View ssv445's full-sized avatar

Shyam Verma ssv445

View GitHub Profile
@ssv445
ssv445 / cron-commit.sh
Created July 17, 2014 09:39
auto commit folder with changed file as commit message
#!/bin/bash
# move to www folder
cd /var/www
rm -f commit.msg
# add files
git add .
# build commit message
@ssv445
ssv445 / index.js
Last active September 2, 2015 11:05 — forked from MoOx/index.js
Export/import github labels
// go on you labels pages
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/popomore/github-labels !
var labels = [];
[].slice.call(document.querySelectorAll(".label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),
@ssv445
ssv445 / gist:3609373
Created September 3, 2012 13:35
PayPlans MySQL Query app : how to avoid few events during upgrades
class PayplansAppMysqlPeter extends PayplansAppMysqlquery
{
protected $_location = __FILE__;
public function onPayplansSubscriptionBeforeSave($prev, $new)
{
if(
!($prev && $prev->getStatus() == PayplansStatus::SUBSCRIPTION_ACTIVE) // it was not a previously active subs
&& $new->getStatus() == PayplansStatus::SUBSCRIPTION_ACTIVE // we are activating it
&& $new->getOrder()->getParam('upgrading_from',0) // its a upgrade
@ssv445
ssv445 / README.md
Created November 24, 2015 18:58 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@ssv445
ssv445 / vhost.py
Created October 26, 2013 04:49 — forked from fideloper/vhost.py
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
import getopt
#
# Show Usage, Output to STDERR
@ssv445
ssv445 / create-db-user.sh
Created November 8, 2013 07:04
This script creates a database 'db' and a user as 'username' with given password 'pass'. It also grant 'username' ALL access to 'db'. Works on any linux.
#!/bin/bash
# A shell script to add mysql database, username and password.
# -------------------------------------------------------------------------
_db="$1"
_user="$2"
_pass="$3"
## Mysql root settings ##
_madminuser='root'
_madminpwd='mysql-root-password'
@ssv445
ssv445 / change-timezone.sh
Created November 8, 2013 16:16
bash command to change timezone on your linux machine
echo "Asia/Kolkata" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
@ssv445
ssv445 / update-joomla-config.php
Last active December 27, 2015 18:59
PHP CLI script to update Joomla configuration file
<?php
//
$joomlaroot = isset($argv[1]) ? $argv[1] : die("First argument required and it should be absolute-joomla-root-path");
$i=2;
$args = array();
while($i <= $argc){
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@ssv445
ssv445 / gist:dfeda39756cf7bfe3f38550c50673dce
Created July 22, 2018 07:10 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter