Skip to content

Instantly share code, notes, and snippets.

View gautham20's full-sized avatar

Gautham Kumaran gautham20

View GitHub Profile
@gautham20
gautham20 / pytorch_hooks.py
Last active July 13, 2019 07:58
Using hooks in pytorch
class Hook():
def __init__(self, m:nn.Module, hook_func:HookFunc, is_forward:bool=True, detach:bool=True):
self.hook_func,self.detach,self.stored = hook_func,detach,None
f = m.register_forward_hook if is_forward else m.register_backward_hook
self.hook = f(self.hook_fn)
self.removed = False
def hook_fn(self, module:nn.Module, input:Tensors, output:Tensors):
if self.detach:
input = (o.detach() for o in input ) if is_listy(input ) else input.detach()
{
'uniq_id': 'b129a98c7c0e905ca82fd73db63d9bd0',
'product_url': 'http://www.flipkart.com/mario-gotze-women-s-printed-casual-orange-shirt/p/itmejrchnshfzygz?pid=SHTEJRCHC5KESPYX',
'product_name': "Mario Gotze Women's Printed Casual Orange Shirt",
'pid': 'SHTEJRCHC5KESPYX',
'retail_price': 1499.0,
'discounted_price': 899.0,
'image': 'http://img5a.flixcart.com/image/shirt/x/z/8/rrcls-w-6107-mario-gotze-xl-original-imaejqq4yqhsfepr.jpeg',
'description': "Key Features of Mario Gotze Women's Printed Casual Orange Shirt Fit: Slim Suitable For: Western Wear Sleeve: Full Sleeve Fabric: Cotton Color:Orange Pattern:Printed Number Of Contents In Package:1,Mario Gotze Women's Printed Casual Orange Shirt Price: Rs. 899 1 shirt,Specifications of Mario Gotze Women's Printed Casual Orange Shirt General Details Pattern Printed Ideal For Women's Occasion Casual Shirt Details Sleeve Full Sleeve Number of Contents in Sales Package Pack of 1 Brand Fit Slim Fabric Cotton Fit Slim Placket Classic Collar Additional Details St
@gautham20
gautham20 / pypika_custom_fn.py
Created December 7, 2018 13:08
adding custom functions to query in pypika
from pypika import Table, Query
from pypika.terms import Function
class ToUnixtime(Function):
def __init__(self, input):
super(ToUnixtime, self).__init__('to_unixtime', input)
actions = Table('test.actions')
@gautham20
gautham20 / v2_add_widgets_to_a_new_page
Last active June 1, 2017 10:02
Add Widgets to a New Page
##Add Widgets to A New Page
- Click on **Folders**, **New Folder**
- Enter a Folder Name and Click on **Create**
- In the newly created folder click on **Menu Icon** in the right corner and click on **add new trigger**
- Enter a name for the trigger, for example, assuming we are adding the widget to **Explore Page**, trigger name can be **Explore Page**
- Click on **Trigger Configuration** and select **DOM Ready**
- click on **Some DOM Ready Events**
- In the first option select **Page Path** from the drop down list
- In the second option select **contains**
@gautham20
gautham20 / V2_Publish_the_widgets
Last active May 28, 2017 22:45
Publish The Widgets
<h2>Preview the Widgets</h2>
- Click on **Preview** button
![enter image description here](http://i.imgur.com/Sd8D5Pe.png)
> If any steps were off-target in the process, you might face errors at this point. kindly contact us for further assistance.
- A Preview mode bar will appear in the dashboard
![enter image description here](http://i.imgur.com/shvJZx2.png)
@gautham20
gautham20 / v2_Change_the_widget_position
Last active May 28, 2017 22:46
Changing the Display Position of Widget
<h2>Changing the Display Position of Widget</h2>
- Click on **Folder**, and click on **Home Page** or **Product Page**, depending on the widget you want to change.
- Click on the **Menu** Icon in the top right corner and select **Add new Variable**
![enter image description here](http://i.imgur.com/LqDm0IN.png)
- Replace **Untitled Variable** with any **variable name** for example **Header Page Position 1**. (Keep Note of this **variable name** as it will be used again) Click on **Variable Configuration**
![enter image description here](http://i.imgur.com/wnwjKqD.png)
@gautham20
gautham20 / V2_Adding_Custom_Header
Last active May 28, 2017 22:45
Adding Custom Header
<h2> Creating a Customizable Widget Header </h2>
To add a customizable header to widget, follow the steps below.
- Click on **Folder**, **widget titles**
- Click on the **Menu** Icon in the top right corner and select **Add new Variable**
![enter image description here](http://i.imgur.com/Noqc7IL.png)
- Replace **Untitled Variable** with any **variable name** for example **Trending Products Header**. (Keep Note of this **variable name** as it will be used again) Click on **Variable Configuration**
@gautham20
gautham20 / V2_Adding_Custom_CSS
Last active June 1, 2017 09:21
Adding Custom Css
<h2> Adding Custom CSS for a Widget </h2>
To add a customizable header to widget, follow the steps below.
- Click on **Folder**, and click on **Home Page** or **Product Page**, depending on the widget you want to add CSS to.
- Click on the **Menu** Icon in the top right corner and select **Add new Tag**
![enter image description here](http://i.imgur.com/iOgfokt.png)
- In the Create Tag page replace **untitled tag** with any widget name.For Example **Trending Product CSS** And click on the **Tag Configuration**
![hpw](http://i.imgur.com/tATgb8b.png)
@gautham20
gautham20 / V2_Add_Widget_GTM
Last active June 8, 2017 06:02
Add Widget
Adding Your Own Widget
======================
Any Product List created in the Yfret portal can be added as a custom widget to your site.
<h2>Creating a Product List</h2>
- Login to your **Yfret Portal**.
@gautham20
gautham20 / v2_GTM_Importing
Last active May 28, 2017 22:41
Importing GTM
Adding Custom Web Widgets Using Google Tag Manager
==================================================
Importing GTM scripts
---------------------
To add custom widgets import the file provided into GTM by following these steps.
1. Login to your [google tag manager console](https://tagmanager.google.com/#/home)
2. Click on **Admin** tab
3. Click on **Import Container**