Skip to content

Instantly share code, notes, and snippets.

View rintoug's full-sized avatar

Rinto George rintoug

View GitHub Profile
@rintoug
rintoug / form.php
Last active February 20, 2017 10:06
Server Side Form Validation using Regular Expressions
<?php
//Declaring the variables
$error_name = '';
$error_email= '';
$error_gender ='';
//Validation part
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
@rintoug
rintoug / code1.sh
Created March 9, 2017 05:47
How To Install and Configure Varnish with Apache on Ubuntu 16.04
sudo apt-get update
sudo apt-get install varnish
@rintoug
rintoug / code2.sh
Created March 9, 2017 05:49
How To Install and Configure Varnish with Apache on Ubuntu 16.04
DAEMON_OPTS="-a :6081\
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
@rintoug
rintoug / code3.sh
Created March 9, 2017 05:50
How To Install and Configure Varnish with Apache on Ubuntu 16.04
# cp /lib/systemd/system/varnish.service /etc/systemd/system/
# nano /etc/systemd/system/varnish.service
@rintoug
rintoug / code4.sh
Created March 9, 2017 05:52
How To Install and Configure Varnish with Apache on Ubuntu 16.04
[Unit]
Description=Varnish HTTP accelerator
[Service]
Type=forking
LimitNOFILE=131072
LimitMEMLOCK=82000
ExecStartPre=/usr/sbin/varnishd -C -f /etc/varnish/default.vcl
ExecStart=/usr/sbin/varnishd -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
ExecReload=/usr/share/varnish/reload-vcl
@rintoug
rintoug / code5.sh
Created March 9, 2017 05:53
How To Install and Configure Varnish with Apache on Ubuntu 16.04
ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secr
@rintoug
rintoug / node.html.twig
Created March 12, 2017 04:48
How to Create a Node Override in Drupal 8
{#
/**
* @file
* Default theme implementation to display a node.
*
* Available variables:
* - node: The node entity with limited access to object properties and methods.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - node.getCreatedTime() will return the node creation timestamp.
@rintoug
rintoug / gist:ee81e8c4d0e9e116e908dbc7c4287024
Last active March 12, 2017 15:57
Display A Search Box on your Site Search Results in Google search
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.yoursite.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.yoursite.com/?s={your_search_term}",
"query-input": "required name=your_search_term"
}
@rintoug
rintoug / create_magento.php
Created March 12, 2017 16:52
Magento create category programmatically
function createCategory(){
$parentId = 1;// Any of your parent category
$category = Mage::getModel('catalog/category');
$category->setName('My First Category');
$category->setUrlKey('My-First-Category');
$category->setIsActive(1); // to make active
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(1); // This is for active anchor
$category->setStoreId(Mage::app()->getStore()->getId());
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
@rintoug
rintoug / facebook.php
Last active March 23, 2017 13:04
Gettting facebook events in php and curl
$access_token = '398021147245479|1e3e221bc154a0fdbbf5372d80a35318';
$graph_url= "https://graph.facebook.com/TheToyStore.ME/events";
$post_datta = "access_token=" .$access_token."&method=get&fields=cover,description,name";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $graph_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_datta);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);