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
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")); |
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
// Every event belongs to a calendar, so grab the first writable calendar | |
nylas.calendars.list({}).then(function(calendars) { | |
cal = null; | |
for(var i = 0; i < calendars.length; i++) { | |
if (calendars[i].readOnly != true) { | |
cal = calendars[i]; | |
break; | |
} | |
} |
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 convert_overloaded_post(request): | |
""" | |
Convert a POST method with a hidden field | |
named _method to a PUT or a DELETE | |
""" | |
request._load_post_and_files() | |
if request.method == "POST": | |
if hasattr(request.POST, "_method"): | |
if request.POST["_method"] == "PUT": | |
request.method = "PUT" |
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
require 'rake' | |
task :default => :compile_templates | |
task :clean_compiled_file do | |
if File.exist?('release.js') | |
File.unlink('release.js') | |
end | |
end |
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 django import template | |
from django.contrib.sites.models import Site | |
from urlparse import urlparse | |
import datetime | |
register = template.Library() | |
@register.filter(name='dayinweek', is_safe=True, expects_localtime=True) | |
def dayincurrentweek(day): | |
if day == datetime.date.today(): |
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
#!/usr/bin/env python | |
import os | |
import sys | |
import optparse | |
def print_usage(): | |
print "usage: vault-diff --vault-password file --rev1 revision1 --rev2 revision2 --file file" | |
def main(): | |
parser = optparse.OptionParser() |
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
// je fais une fonction pour calculer une correction sur des images | |
function composeImages($bottomImage, $topImage, $x, $y) { | |
$y_diff = $topImage->getImageHeight / 2; // ici j'oublie de mettre une parenthèse à mon appel de fonction | |
// ça passe parce que php met ça à 0 | |
$corrected_y = $y - $y_diff; // du coup il n'y a pas de correction | |
// j'en déduis que ça marche et je m'autocongratule | |
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
// Taken from Mozilla's Public Suffix List (https://publicsuffix.org/). License: MPL | |
domains = ["ac", | |
"com.ac", | |
"edu.ac", | |
"gov.ac", | |
"net.ac", | |
"mil.ac", | |
"org.ac", | |
"ad", | |
"nom.ad", |
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
<?php | |
$ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"; | |
$ch = curl_init("https://api.nylas.com/events"); | |
# Pass the access token as an HTTP basic auth username | |
curl_setopt($ch, CURLOPT_USERPWD, $ACCESS_TOKEN . ":"); | |
# Return response instead of printing. | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
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
<?php | |
$ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"; | |
$CALENDAR_ID = "The id of a calendar you got from the Nylas /calendars API"; | |
$ch = curl_init("https://api.nylas.com/events"); | |
# Setup request to send json via POST. | |
$payload = json_encode( | |
array("title" => "Alan Turing Birthdate", | |
"description" => "Alan Turing Birthdate", |
OlderNewer