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
def validate_query(query, possible_columns): | |
q = validate_query_structure(query) | |
sort_field = q.get('_sortField') | |
filters = q.get('_filters', []) | |
columns = [field_name for field_name in filters] | |
if sort_field is not None: | |
columns.append(sort_field) |
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
def _make_context_immutable(context): | |
"""Best effort attempt at turning a properly formatted context | |
(either a string, dict, or array of strings and dicts) into an | |
immutable data structure. | |
If we get an array, make it immutable by creating a tuple; if we get | |
a dict, copy it into a MappingProxyType. Otherwise, return as-is. | |
""" | |
def make_immutable(val): | |
if isinstance(val, Mapping): |
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
const element = document.getElementById("test"); | |
const cssObj = window.getComputedStyle(element, null); | |
let text = ""; | |
for (x in cssObj) { | |
cssObjProp = cssObj.item(x) | |
text += cssObjProp + " = " + cssObj.getPropertyValue(cssObjProp) + "<br>"; | |
} |
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
>> y1 = Yeah('yes') | |
>> y1.name | |
__getattribute__ name | |
'yes' | |
>> y1.foo | |
__getattribute__ foo | |
__getattr__ foo | |
>> y1.foo | |
__getattribute__ foo | |
'orphan' |
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
class Yeah(object): | |
def __init__(self, name): | |
self.name = name | |
# Gets called when an attribute is accessed | |
def __getattribute__(self, item): | |
print '__getattribute__ ', item | |
# Calling the super class to avoid recursion | |
return super(Yeah, self).__getattribute__(item) | |
# Gets called when the item is not found via __getattribute__ | |
def __getattr__(self, item): |
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
""" Симуляция "Жизни". | |
Игра жизни Конвея — это классическая автоматизация, созданная в 1970 году Джоном | |
Конвей. https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life | |
Упражнение для практики | |
1. Можете ли вы поменять изобрженния точек? | |
2. Можете ли вы ускорить симуляцию? | |
3. Как бы вы изменили начальное состояние? |
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
# coding=utf-8 | |
from countryinfo import CountryInfo | |
country = CountryInfo('Bangladesh') | |
country.geo_json() | |
# returns object of GeoJSON data | |
{ | |
'features': [ |
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
package main | |
import ( | |
"log" | |
"os" | |
"strconv" | |
"github.com/hibiken/asynq" | |
"github.com/joho/godotenv" | |
"github.com/vert3xo/mcscan/tasks" |
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 fixedFromCharCode (codePt) { | |
2 | |
if (codePt > 0xFFFF) { | |
3 | |
codePt -= 0x10000; | |
4 | |
return String.fromCharCode(0xD800 + (codePt >> 10), 0xDC00 + (codePt & 0x3FF)); | |
5 | |
} else { | |
6 |
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
# Python code showing practical | |
# use of format_map() function | |
def chk_msg(n): | |
# input stored in variable a. | |
a = {'name':"George", 'mesg':n} | |
# use of format_map() function | |
print('{name} has {mesg} new messages'.format_map(a)) |