Skip to content

Instantly share code, notes, and snippets.

View srmklive's full-sized avatar

Raza Mehdi srmklive

View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@srmklive
srmklive / gist:aa377b9995acebc0e16f
Created October 24, 2015 15:25
Automatically trigger stripe checkout form
<form name="checkoutform" action="/payment" method="POST">
<input type="hidden" name="stripeToken" id="stripe_token" />
</form>
<script src="https://checkout.stripe.com/checkout.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<button id="customButton" style="display:none;">Purchase</button>
<script>
var handler = StripeCheckout.configure({
@srmklive
srmklive / gist:887e3aea58fb2e8867bf
Last active November 2, 2015 13:32
Install NodeJS on Linux using Standard Binary packages downloaded from https://nodejs.org
## Step 1: Check System Architecture.
getconf LONG_BIT
uname -p
## Step 2: Download the latest version. current LTS release is 4.2.1.
wget https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-x64.tar.gz
## Step 3: Installing the downloaded binary
tar -C /usr/local --strip-components 1 -xzf node-v4.2.1-linux-x64.tar.gz
When running any composer commands, sometimes you see the following error stack:
```
[ReflectionException]
Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist
[ErrorException]
@srmklive
srmklive / gist:b87549aeb9a65da7bf938a13410c30ff
Last active April 11, 2016 09:19
Remove composer error: proc_open(): fork failed - Cannot allocate memory
When running composer commands, sometimes you may see Download exception errors, and also this error message:
```
proc_open(): fork failed - Cannot allocate memory
```
To correct this error, you need to enable swap. You can enable swap by running the following commands:
```
/bin/dd if=/dev/zero of=/swapfile bs=1M count=4096
# Uncomment the following code to force https mode.
#server {
# listen 80;
# server_name laravel.test;
# return 301 https://laravel.test$request_uri;
#}
server {
listen 80; # comment this line & uncomment the line below to force https mode.
@srmklive
srmklive / docker-destroy-all.sh
Last active June 4, 2020 05:25 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
sudo docker stop $(sudo docker ps -a -q)
# Delete all containers
sudo docker rm $(sudo docker ps -a -q)
# Delete all images
sudo docker rmi $(sudo docker images -q)
# Deleta all volumes
sudo docker volume prune -f
# Delete docker networks
@srmklive
srmklive / docker-remove-dangling-images.sh
Last active July 18, 2018 06:52
Remove all dangling docker containers
sudo docker rmi --force $(sudo docker images -qa -f 'dangling=true')
@srmklive
srmklive / gist:2ca197fd9829c5c57e3a3e957ce739b2
Created October 12, 2018 08:13
Atomically delete keys matching a specific pattern in Redis
# Go to redis terminal using command 'redis-cli'. After redis terminal is opened, type in the following command to remove entries:
EVAL "local keys = redis.call('keys', ARGV[1]) \n for i=1,#keys,5000 do \n redis.call('del', unpack(keys, i, math.min(i+4999, #keys))) \n end \n return keys" 0 prefix:*
@srmklive
srmklive / gist:c9105f88d130f7eb5d9b713ed87d2023
Created October 31, 2018 21:22
(How i fixed) SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
1. First edit the mysql config e.g. /etc/mysql/my.cnf & added the following:
[mysqld]
default_authentication_plugin= mysql_native_password
2. Then run the following command:
mysql_upgrade -u root -p --default-auth=mysql_native_password
3. If above command succeeds, then login into mysql server: