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
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); | |
String[] projection = {PhoneLookup.DISPLAY_NAME}; | |
Cursor c = contentResolver.query(uri, projection, null, null, null); | |
if (c.moveToFirst()) { | |
name = c.getString(c.getColumnIndex(PhoneLookup.DISPLAY_NAME)); | |
} |
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
// Get the preference | |
EditTextPreference textPreference = (EditTextPreference) super.findPreference("text_preference_key"); | |
// Change its value | |
textPreference.setText("Default Value"); |
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.contrib.auth.decorators import login_required | |
from django.utils.decorators import method_decorator | |
from django.views.generic.base import View | |
class LoginRequiredMixin(View): | |
@method_decorator(login_required) | |
def dispatch(self, *args, **kwargs): | |
return super(LoginRequiredMixin, self).dispatch(*args, **kwargs) |
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
{% load navigation %} | |
<!-- Specific path, only when visiting /accounts/ --> | |
<li class="{% active request "^/accounts/$" %}"><a href="/accounts/">Accounts</a></li> | |
<!-- Glob path, when visiting /blog/* example /blog/, /blog/post1/, /blog/post2/, /blog/post2/subitem/, ... --> | |
<li class="{% active request "^/blog/" %}"><a href="/blog/">Blog</a></li> |
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
<? | |
//------------------------------------------------------------------------------ | |
// Description: Function that validates Brazilian CNPJ | |
// Author: Elyézer Mendes Rezende | |
// Inspired by: | |
// http://codigofonte.uol.com.br/codigos/validar-numero-do-cnpj | |
// https://github.com/django/django-localflavor/blob/master/localflavor/br/forms.py | |
//------------------------------------------------------------------------------ | |
function validate_cnpj($cnpj) { |
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
<html> | |
<head> | |
<title>Blink an LED</title> | |
<script src="http://192.168.7.2/bonescript.js" type="text/javascript"></script> | |
<style> | |
#led_status { | |
background-color:red; | |
border-radius:16px; | |
display: inline-block; | |
height:16px; |
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
-- Example table | |
CREATE TABLE ring_buffer (id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT); | |
-- Number 10 on where statement defines the ring buffer's size | |
CREATE TRIGGER delete_tail AFTER INSERT ON ring_buffer | |
BEGIN | |
DELETE FROM ring_buffer WHERE id%10=NEW.id%10 AND id!=NEW.id; | |
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
# Change the version 2.3.2 as needed | |
wget http://swupdate.openvpn.org/community/releases/openvpn-2.3.2.tar.gz | |
tar zxf openvpn-2.3.2.tar.gz | |
cd openvpn-2.3.2 | |
./configure | |
make | |
make install |
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
# Compile a shared library | |
gcc -shared -o libmean.so.1 mean.c |
OlderNewer