$('.typeahead').typeahead({
source: MYDATA
// Typeahead will not select the first suggestion.
// If the user press enter without selecting any suggestion
// the onselect function will be called with the inputted text
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
(function (Array) { | |
var isFunction = function (value) { | |
var getType = {}; | |
return value && getType.toString.call(value) === '[object Function]'; | |
}; | |
var anyItemMeetsPredicate = function (items, predicate) { | |
for (var i=0; i < items.length; i++) { | |
if (predicate(items[i]) === 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
from django.db import models | |
class djobjclone(object): | |
""" | |
Makes a clone of a django model object. | |
The clone is shallow and handicapped. | |
""" | |
def __init__(self, o): | |
assert isinstance(o, models.Model) |
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 class MyProfiler | |
{ | |
public int Calls | |
{ | |
get; | |
private set; | |
} | |
public TimeSpan TotalTime | |
{ |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Text; | |
namespace WebClientMultipartExtension | |
{ | |
public class MultipartFormBuilder | |
{ | |
static readonly string MultipartContentType = "multipart/form-data; boundary="; |
The most simple usage is as follows:
$ replace.py 'foobarz' 'foo bar' myfile.txt
The tool searches for foobarz
on the contents of myfile.txt and replaces it with foo bar
.
The result is written on stdout. This is useful to check if the script is doing what you expect.
If you want the tool to change de file itself, use the -I
argument
(use backups or versioning to avoid losing data):
Python has a synthax to chain comparison operators. For example:
if x > y > z:
print('foo')
if x < y < z:
print('bar')
if x == y == z: