Skip to content

Instantly share code, notes, and snippets.

View monotone.go
package main
import (
cryptorand "crypto/rand"
"math/rand"
"errors"
"sync"
"fmt"
"time"
)
@PirosB3
PirosB3 / main.py
Created Jan 13, 2016
Quora.challenge
View main.py
import itertools
import sys
def non_increasing_range(items, i, j, _c):
try:
d = _c[(i, j)]
return d
except KeyError:
pass
View gist:f3f2af7d1b223efddadb
package main
import "fmt"
type Grid []uint
func (g *Grid) NewGrid(width int, height int) {
for i:=0; i < height; i++ {
*g = append(*g, 0)
}
View gist:523fd62416dc3ad7e9a1
# Let's combine some queries together!
GET /bank/account/_search
{
"query": {
"bool": {
"must": [{
"match": {
"address": "court"
}
}],
View gist:8e93ca5236d395c3954d
# Let's start by checking how many documents we have in the collection
GET /bank/account/_count
# A simple search. The word "Michael" must be fully conatiend somewhere in the specified field.
# A score is given to each document retrieved
GET /bank/account/_search
{
"query": {
"match": {
"address": "Temple Court"
View django-core-patch.diff
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index d8f7fe5..7a7c651 100644
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -560,9 +560,10 @@ class ModelAdminChecks(BaseModelAdminChecks):
id='admin.E105',
)
]
- elif not issubclass(inline.model, models.Model):
- return must_be('a Model', option='%s.model' % inline_label,
View gist:7291a2a5cbe2c371126c
import heapq
import itertools
def _insert(dic, c):
try:
return dic[c]
except KeyError:
dic[c] = {}
return dic[c]
View random_generator.py
import random
import math
def random_number_generator(base, power, base_num):
if power == 1:
return base()
return int((base_num ** (power-1)) * base() + random_number_generator(base, power-1, base_num))
def generate_given(rand_num, target_rand_range):
if target_rand_range < rand_num:
View sudoku_solver.py
import copy
import itertools
from collections import defaultdict
import numpy as np
def get_minigrid_for_coord(i, j):
h = i / 3
w = j / 3
return w, h
View sudoku_solver.py
import copy
import itertools
from collections import defaultdict
import numpy as np
def get_minigrid_for_coord(i, j):
h = i / 3
w = j / 3
return w, h