This file contains hidden or 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
package main | |
import ( | |
"bufio" | |
"io/ioutil" | |
"os" | |
"strconv" | |
) | |
const ( |
This file contains hidden or 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
package main | |
func main() { | |
} | |
func Merge2Channels(f func(int) int, in1 <-chan int, in2 <-chan int, out chan<- int, n int) { | |
go func(f func(int) int, in1 <-chan int, in2 <-chan int, out chan<- int) { | |
done := make(chan bool, n*2) | |
results := make([]*int, n*2) |
This file contains hidden or 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 read_file_by_chunks(filename): | |
chunk_size = 9+1 | |
with open(filename) as f: | |
read_bytes = 0 | |
while True: | |
chunk = f.read(chunk_size) | |
chunk = chunk.strip() | |
if not chunk: | |
break | |
if '\n' in chunk: |
This file contains hidden or 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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strconv" | |
"strings" | |
) |
This file contains hidden or 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
class City(models.Model): | |
name = models.CharField(max_length=255) | |
class Person(models.Model): | |
city = models.ForeighKey(City) | |
first_name = models.CharField(max_length=255) | |
last_name = models.CharField(max_length=255) |
This file contains hidden or 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 net_mask(cidr): | |
cidr, mask = cidr.split('/') | |
mask = int(mask) | |
bin_mask_str = mask * '1' + (32 - mask) * '0' | |
mask_lst = [int(bin_mask_str[n*8:(n+1)*8], 2) for n in range(4)] | |
net_addr = [] | |
broadcast = [] | |
for oct in zip(cidr.split('.'), mask_lst): |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import re | |
s = re.compile(r"\[(id\d+)\|(.*)\]") | |
r = s.search("[id12345678|Саша], бла бал балв выф пв пвыавыфавы аыфа") | |
print "id %s" % r.group(1) | |
print "name %s" % r.group(2) |
This file contains hidden or 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
@media screen and (max-width: 980px) { | |
.block { position: static } | |
.tower {color: red} | |
} |
This file contains hidden or 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
<!-- 99% форм так делаются--> | |
<form> | |
<input value="" type="text" placeholder="поиск..."/> | |
<!-- Это кнопка --> | |
<input type="submit" value="Найти"/> | |
</form> |