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
// 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
vagrant@precise64:/vagrant/tests$ py.test -n 2 general/ | |
================================================= test session starts ================================================== | |
platform linux2 -- Python 2.7.3 -- py-1.4.26 -- pytest-2.6.4 | |
plugins: xdist, httpretty | |
gw0 [24] / gw1 okINTERNALERROR> Traceback (most recent call last): | |
INTERNALERROR> File "/usr/local/lib/python2.7/dist-packages/_pytest/main.py", line 84, in wrap_session | |
INTERNALERROR> doit(config, session) | |
INTERNALERROR> File "/usr/local/lib/python2.7/dist-packages/_pytest/main.py", line 122, in _main | |
INTERNALERROR> config.hook.pytest_runtestloop(session=session) | |
INTERNALERROR> File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py", line 413, in __call__ |
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
#!/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
require 'openssl' | |
# verify_webhook: check that a webhook was sent by a Nylas server. | |
# params: | |
# - request: the request object you get from Rails, | |
# - nylas_app_secret: your app secret. | |
def verify_webhook(request, nylas_app_secret) | |
digest = OpenSSL::Digest.new('sha256') | |
data = request.body.read | |
digest = OpenSSL::HMAC.hexdigest(digest, nylas_app_secret, 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
// 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", |
OlderNewer