This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def configure_fields(fields): | |
""" | |
Configures form field with bootstrap style | |
Input forms fields | |
Output formatted form fields | |
""" | |
for field in fields: | |
if isinstance(fields[field].widget, Textarea): | |
fields[field].widget.attrs['rows'] = '3' | |
fields[field].widget.attrs['class'] = 'form-control' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def instantiate_formset_data(formset_class, data, instances=[], initial=None, action="add"): | |
""" | |
Input: | |
Formset_class | |
data - Python Dict type form data | |
Instances - [] if its a CreateForm, or list of instances in case of EditForm | |
Initial - Initial data if any | |
Action = define edit/Add action | |
Output: data --> Formset style Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def addtoprofile(request, count): | |
count = int(count) | |
formsets = (Form1, Form2, Form3) | |
try: | |
Form = Form[count] | |
except IndexError: | |
return redirect("/") | |
next_url = "Next" | |
if count == len(formsets): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table = pd.pivot_table(df, values='Quantity', index =['Country','Region'], columns=["Year","Requester"], aggfunc=[np.sum]) | |
result_df = table | |
for i in range(2): | |
df2 = table.groupby(level=i).sum() | |
if i==0: | |
tot_sum = df2.sum(axis=i) | |
df2 = pd.concat([df2,pd.DataFrame([tot_sum]).rename({0:"Grand"})]).sort_index(level=[0]) | |
df2.index = pd.MultiIndex.from_arrays([df2.index.values + '_Total', | |
len(df2.index) * [''], | |
len(df2.index) * ['']]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import TodoList from '../ui/TodoList'; | |
import StateProvider from './StateProvider'; | |
class App extends Component { | |
render() { | |
return ( | |
<StateProvider> | |
<TodoList/> | |
</StateProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ele = document.getElementsByClassName("style-scope ytd-thumbnail-overlay-time-status-renderer") | |
for(i=0, i<ele.length, i+=){ | |
if (ele[i].tagName == "span"){ | |
label = ele[i].getAttribute("aria-label") | |
times = parseFloat(ele[2].textContent.replace(":", ".").trim()) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mutagen.mp4 import MP4 | |
duration = 0 | |
for file in os.listdir(): | |
mp4 = MP4(file) | |
duration += mp4.info.length | |
print (duration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Linkedin Unfortunately follows every collection, once in a while I use this script to clean it up | |
a = document.getElementsByClassName("follows-recommendation-card__follow-btn") | |
b = Array.from(a) | |
b.forEach((x) => { | |
x.click() | |
}) |
OlderNewer