Skip to content

Instantly share code, notes, and snippets.

View geovannyAvelar's full-sized avatar

Giovanni Avelar geovannyAvelar

View GitHub Profile
# Sort a list of dictionary objects by a key - case sensitive
from operator import itemgetter
mylist = sorted(mylist, key=itemgetter('name'))
# Sort a list of dictionary objects by a key - case insensitive
mylist = sorted(mylist, key=lambda k: k['name'].lower())
@jorilallo
jorilallo / gist:3686737
Created September 9, 2012 19:33
Google Contacts API authentication with gdata and OAuth2
import gdata
import json
import requests
# More examples:
# https://github.com/millioner/Python-contact-importer/blob/master/contact_importer/providers/google.py
# https://github.com/jtauber/django-friends/blob/master/friends/importer.py
# GData with access token
token = gdata.gauth.OAuth2Token(
@weapp
weapp / nginx.conf
Created August 4, 2014 17:21
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
@eightyknots
eightyknots / avregex.md
Last active July 7, 2024 20:19
AvReg: Aviation regex match toolkit

AvReg: The Aviation RegEx Match Toolkit

General Tips

  • The PCRE flavour of RegEx is used here.
  • Append the i modifier to the end of the regex to make any pattern case-insensitive.

Aircraft

| Purpose | Description | RegEx | Example |

@dvt32
dvt32 / ALGORITHMO-19-Naive-String-Search-Implementation.java
Last active July 30, 2020 12:16
ALGORITHMO #19 - Naive String Search Implementation
public class StringSearch {
public static int getSubstringStartIndex(String text, String pattern) {
int n = text.length();
int m = pattern.length();
for (int startIndex = 0; startIndex <= ( n - m ); ++startIndex) {
int i = 0;
for (i = 0; i < m; ++i) {
if (pattern.charAt(i) != text.charAt(startIndex + i)) {
@AlexEshoo
AlexEshoo / IEEE 754 Conversion Python
Last active January 16, 2024 15:22
IEEE 754 Conversion Python
Used for gist name.