Skip to content

Instantly share code, notes, and snippets.

View khamidou's full-sized avatar
🎧

Karim Hamidou khamidou

🎧
View GitHub Profile
<form method = "POST" action="resultat.html"> {% csrf_token %}
<select name="entry_to_delete">
{% for product_name, product_id in history %}
<option value={{ product_id }}>{{ product_name }}</option>
{% endfor %}
</select>
<input type = "submit" value = "Submit">
</form>
from django.db import models
from django import forms
class Niveau(forms.Form):
choix_niveau=(
('deb', 'debutant'),
('int', 'intermédiaire'),
('av', 'avancé'))
niveau=forms.ChoiceField(choices=choix_niveau)
@khamidou
khamidou / exponential_backoff.rb
Last active April 21, 2022 13:44 — forked from nathanl/exponential_backoff.rb
Exponential backoff with jitter in Ruby
# Exponential backoff in Ruby
begin
make_request
rescue RequestError => e
if retries <= max_retries
retries += 1
sleep 2 ** retries + rand(20)
retry
else
raise "Timeout: #{e.message}"
@khamidou
khamidou / NylasAuthResponse.cs
Last active August 29, 2015 14:28 — forked from CiprianPorumbescu/NylasAuthResponse.cs
An example of how to authorize Nylas from .Net
public async Task<ActionResult> NylasAuthenticationResult(string code)
{
using (HttpClient httpClient = new HttpClient())
{
// tried as x-www-form-encoded
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("client_id", "cf7jhxlkkvimkxvd2vnkkzci"));
postData.Add(new KeyValuePair<string, string>("client_secret", "your_secret"));
postData.Add(new KeyValuePair<string, string>("grant_type ", "authorization_code"));