Wednesday, November 20, 2024

Python code for portalquery.just.ro/CautareDosare API

import requests
import xml.dom.minidom
# http://portalquery.just.ro/query.asmx?WSDL
# http://portalquery.just.ro/query.asmx
# https://portal.just.ro/SitePages/acces.aspx

url = "http://portalquery.just.ro/query.asmx"

payload = """<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
        <CautareDosare2
            xmlns="portalquery.just.ro">
            <numarDosar>1268/2/2022</numarDosar>
            <obiectDosar></obiectDosar>
            <numeParte></numeParte>
            <institutie>CurteadeApelBUCURESTI</institutie>
            <dataStart>2022-01-01</dataStart>
            <dataStop>2024-01-01</dataStop>
            <dataUltimaModificareStart>2022-01-01</dataUltimaModificareStart>
            <dataUltimaModificareStop>2024-01-01</dataUltimaModificareStop>
        </CautareDosare2>
    </soap12:Body>
</soap12:Envelope>"""
headers = {
'Content-Type': 'application/soap+xml; charset=utf-8',
'SOAPAction': 'portalquery.just.ro/CautareDosare2'
}

response = requests.request("POST", url, headers=headers, data=payload)

dom = xml.dom.minidom.parseString(response.text)
pretty_xml_as_string = dom.toprettyxml()
print(pretty_xml_as_string)


url = "http://portalquery.just.ro/query.asmx"

payload = """<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Body>
        <CautareDosare
            xmlns="portalquery.just.ro">
            <numarDosar>1269/2/2022</numarDosar>
            <obiectDosar></obiectDosar>
            <numeParte></numeParte>
            <institutie>CurteadeApelBUCURESTI</institutie>
            <dataStart>2022-01-01</dataStart>
            <dataStop>2024-01-01</dataStop>
            <dataUltimaModificareStart>2022-01-01</dataUltimaModificareStart>
            <dataUltimaModificareStop>2024-01-01</dataUltimaModificareStop>
        </CautareDosare>
    </soap:Body>
</soap:Envelope>"""
headers = {
'Content-Type': 'application/soap+xml; charset=utf-8',
'SOAPAction': 'portalquery.just.ro/CautareDosare'
}

response = requests.request("POST", url, headers=headers, data=payload)

dom = xml.dom.minidom.parseString(response.text)
pretty_xml_as_string = dom.toprettyxml()
print(pretty_xml_as_string)

'''
Serviciul web portal.just.ro permite accesul la datele despre dosare, părţi şi şedinţe de judecată.
Adresa serviciului web este: http://portalquery.just.ro/query.asmx

    Serviciul web permite accesul la date folosind două metode de interogare:
    - căutare dosare
    - căutare şedinţe

 
Căutarea dosarelor
 
Căutarea dosarelor se face după următorii parametri de interogare:
- număr dosar
- obiect dosar
- nume parte
- instanţă
- perioadă (dosare dintr-un interval de timp)
 
La o interogare se pot folosi combinaţii de parametri. Se va completa obligatoriu cel puţiu unul din parametrii: număr dosar, obiect dosar, nume parte.
Notă: lista rezultată la o interogare va conţine maxim 1000 dosare.
 
Informaţiile obţinute sunt:
- numărul dosarului (format numar unic)
- număr în format vechi (dacă există)
- data dosarului
- instanţa dosarului
- departamentul (secţia)
- categoria cazului
- stadiul procesual al dosarului
- lista de parţi din dosar
- lista de termene ale dosarului
- lista de căi de atac

Căutarea şedinţelor
 
Căutarea şedinţelor se face după următorii parametri de interogare:
- data şedinţă (obligatoriu)
- instanţa (obligatoriu)
 
Informaţiile obţinute sunt:
- departamentul (secţia)
- numele completului de judecată
- data şedinţei
- ora şedinţei
- lista de dosare din şedinţă
 
Serviciul Web a fost creat folosind platforma .NET 3.5 şi ASP.NET. Astfel, cei care utilizează aceste servicii folosind .NET se vor putea integra uşor. Totuşi, nu ar trebui să fie nici o dificultate pentru apelul acestor servicii folosind orice altă platformă de dezvoltare software (PHP, Java, etc.).
 
Documentaţia detaliată a serviciului poate fi consultată accesând documentul:

 Documentarea serviciului web de conectare programatică la date şi export.docDocumentarea serviciului web de conectare programatică la date şi export.doc
'''

Tuesday, November 19, 2024

Python Jinja Checks

 "Testing for List Existence in Jinja2 Templates"

  1. Description: Developers often search for methods to check if a variable in a Jinja2 template is a list or not.

    {# Code Implementation: #}
    {% if my_list is iterable %}
        <p>my_list is a list!</p>
    {% else %}
        <p>my_list is not a list!</p>
    {% endif %}
  2. "Jinja2: Testing List Length"

    Description: Demonstrating how to test the length of a list variable in Jinja2 templates.

    {# Code Implementation: #}
    {% if my_list|length > 0 %}
        <p>my_list is not empty!</p>
    {% else %}
        <p>my_list is empty!</p>
    {% endif %}
  3. "Checking for Empty List in Jinja2"

    Description: Providing a method to determine if a list variable is empty within a Jinja2 template.

    {# Code Implementation: #}
    {% if my_list %}
        <p>my_list is not empty!</p>
    {% else %}
        <p>my_list is empty!</p>
    {% endif %}
  4. "Jinja2: Testing List Contents"

    Description: Testing whether a list variable contains specific elements in Jinja2 templates.

    {# Code Implementation: #}
    {% if 'desired_element' in my_list %}
        <p>desired_element is in my_list!</p>
    {% else %}
        <p>desired_element is not in my_list!</p>
    {% endif %}
  5. "Jinja2: Looping Over List Items"

    Description: Showing how to iterate over each item in a list variable within Jinja2 templates.

    {# Code Implementation: #}
    {% for item in my_list %}
        <p>{{ item }}</p>
    {% endfor %}
  6. "Jinja2: Testing List Type"

    Description: Verifying whether a variable in Jinja2 is specifically a list type.

    {# Code Implementation: #}
    {% if my_list is iterable and my_list is not string %}
        <p>my_list is a list!</p>
    {% else %}
        <p>my_list is not a list!</p>
    {% endif %}
  7. "Jinja2: Checking List Equality"

    Description: Testing if two list variables are equal in Jinja2 templates.

    {# Code Implementation: #}
    {% if my_list == another_list %}
        <p>my_list and another_list are equal!</p>
    {% else %}
        <p>my_list and another_list are not equal!</p>
    {% endif %}
  8. "Jinja2: Testing List Indexing"

    Description: Accessing specific elements of a list variable by index in Jinja2 templates.

    {# Code Implementation: #}
    <p>{{ my_list[0] }}</p>
  9. "Jinja2: Checking List Membership"

    Description: Verifying if a variable exists in a list within Jinja2 templates.

    {# Code Implementation: #}
    {% if 'desired_element' in my_list %}
        <p>desired_element exists in my_list!</p>
    {% else %}
        <p>desired_element does not exist in my_list!</p>
    {% endif %}
  10. "Jinja2: Testing List Sorting"

    Description: Sorting list elements in Jinja2 templates to facilitate comparisons or display.

    {# Code Implementation: #}
    {% for item in my_list|sort %}
        <p>{{ item }}</p>
    {% endfor %}

Jinja built-in filters and tests (like Django filters)

The Jinja documentation makes an explicit difference between what it calls filters and tests. The only difference is Jinja tests are used to evaluate conditions and Jinja filters are used to format or transform values. In Django there is no such naming difference and an equivalent Jinja test in Django is simply called a Django filter.

The syntax to apply Jinja filters to template variables is the vertical bar character | , also called a 'pipe' in Unix environments (e.g.{{variable|filter}}). It's worth mentioning you can apply multiple filters to the same variable (e.g.{{variable|filter|filter}}). The syntax to apply Jinja tests uses the is keyword along with a regular conditional to evaluate the validity of a test (e.g. {% if variable is divisibleby 10 %}do something{% endif %}).

In the upcoming sections, I'll add the reference (Test) to indicate it's referring to a Jinja test vs. a Jinja filter. I'll also classify each Django built-in filter & test into functional sections so they are easier to identify. I'll define the broadest category 'Strings, lists, dictionaries, numbers and objects' for filters and tests that pplicable for most scenarios and then more specialized sections for each data type, including: 'String and lists', 'Dictionaries and objects', Strings, Numbers, Spacing and special characters, Development and testing and Urls.

Strings, lists, dictionaries, numbers and objects

  • default or d.- The default or d filter is used to specify a default value if a variable is undefined or is false (i.e. it doesn't exist or is empty). For example, the filter statement {{variable|default("no value")}} outputs no value only if the variable is undefined, otherwise it outputs the variable value. If in addition you want to provide a default value for a variable that evaluates to false, is None or is an empty string, you have to add true as a second filter parameter (e.g. {{variable|default("no value",true)}} outputs no value if the variable is undefined, false, is None or is an empty string).

  • defined (Test).- The defined test is used to check if a variable is defined, if a variable is defined this tests return true. Listing 4-19 illustrates an example of the defined test.

Listing 4-19 Jinja defined test

{% if variable is defined %}
    value of variable: {{ variable }}
{% else %}
    variable is not defined
{% endif %}
  • none (Test).- The none test is used to check if a variable is none, if a variable is None this tests return true.

  • length or count.- The length filter is used to obtain the length of a value. For example, if a variable contains latte the filter statement {{variable|length}} outputs 5. For a list variable that contains ['a','e','i'] the filter statement {{variable|length}} outputs 3.

  • equalto (Test).- The equalto test checks if an object has the same value as another object. For example {% if coffee.price is equalto 1.99 %} coffee prices equals 1.99 {% endif %}. This works just like the ==, but is more helpful when used with other filters such as selectattr (e.g. {{ users|selectattr("email", "equalto", "webmaster@coffeehouse.com") }}, gets users with email webmaster@coffeehouse.com).

  • string (Test).- The string test checks if a variable is a string (e.g. {% if variable is string %}Yes, the variable is a string!{% endif %}).

  • number (Test).- The number test returns true if a variable is a number.

  • iterable (Test).- The iterable test checks if it's possible to iterate over an object.

  • sequence (Test).- The sequence test checks if the object is a sequence (e.g. a generator).

  • mapping (Test).- The mapping test checks if the object is a mapping (e.g. a dictionary).

  • callable (Test).- The callable test verifies if an object is callable. In Python a function, classes and object instances with a __call__ method are callables.

  • sameas (Test).- The sameas test verifies if an object points to the same memory address than another object.

  • eq or equalto (or ==) (Test).- The eq or equalto tests verify if object is equal.

  • ne (or !=) (Test).- The ne test verifies if an object is not equal.

  • lt or lessthan (or <) (Test).- The lt or lessthan tests verify if an object is less than.

  • le (or <=) (Test).- The le test verifies if an object is less than or equal.

  • gt or greaterthan (or >) (Test).- The gt or greaterthan tests verify if an object is greater than.

  • ge (or <=) (Test).- The ge test verifies if an object is greater than or equal.

  • in (Test).- The in test verifies if a given variable contains a value.

  • boolean (Test).- The boolean test returns true if a variable is a boolean.

  • false (Test).- The false test returns true if a variable is false.

  • true (Test).- The true test returns true if a variable is true.

  • integer (Test).- The integer test returns true if a variable is an integer.

  • float (Test).- The float test returns true if a variable is a float.

Strings and lists

  • reverse.- The reverse filter is used to get inverse representation of a value. For example, if a variable contains latte the filter statement {{variable|reverse}} generates ettal.

  • first.- The first filter returns the first item in a list or string. For example, for a list variable that contains ['a','e','i','o','u'] the filter statement {{variable|first}} outputs a.

  • join.- The join filter joins a list with a string. The join filter works just like Python's str.join(list). For example, for a list variable that contains ['a','e','i','o','u'] the filter statement {{variable|join("--)}} outputs a--e--i--o--u. The join filter also supports joining certain attributes of an object (e.g.{{ users|join(', ', attribute='username') }})

  • last.- The last filter returns the last item in a list or string. For example, for a list variable that contains ['a','e','i','o','u'] the filter statement {{variable|last}} outputs u.

  • map.- The map filter allows you to apply a filter or look up attributes, just like the standard Python map method. For example, if you have list of users but are only interested in outputting a list of usernames a map is helpful (e.g. {{ users|map(attribute='username')|join(', ') }}). In addition, it's also possible to invoke a filter by passing the name of the filter and the arguments afterwards (e.g. {{ titles|map('lower')|join(', ') }} applies the lower filter to all the elements in titles and then joins the items separated by a comma).

  • max.- The max filter selects the largest item in a variable. For example, for a list variable that contains [1,2,3,4,5] the statement {{ variable|max }} returns 5.

  • min.- The min filter selects the smallest item in a variable. For example, for a list variable that contains [1,2,3,4,5] the statement {{ variable|min }} returns 1.

  • random.- The random filter returns a random item in a list. For example, for a list variable that contains ['a','e','i','o','u'] the filter statement {{variable|random}} could output a, e, i, o or u.

  • reject.- The reject filter removes elements that pass a certain test -- see bullets in this chapter section marked as (Test) for acceptable values. For example, for a list variable that contains [1,2,3,4,5] the loop statement with this filter {% for var in variable|reject("odd") %}{{var}}{% endfor %} -- where odd is the Jinja test -- rejects elements that are odd and thus its output is 2 and 4.

  • select.- The select filter selects elements that pass a certain test -- see bullets in this chapter section marked as (Test) for acceptable values. For example, for a list variable that contains [1,2,3,4,5] the loop statement with this filter {% for var in variable|select("odd") %}{{var}}{% endfor %} -- where odd is the Jinja test -- selects elements that are odd and thus its output is 1, 3 and 5.

  • slice.- The slice filter returns a slice of lists. For example, for a variable that contains ["Capuccino"] the filter statement {% for var in variable|slice(4) %}{{var}}{% endfor %} outputs ['C', 'a', 'p'],['u', 'c'],['c', 'i'], ['n', 'o']. It's possible to use the fill_with as a second argument -- which defaults to None -- so all segments contain the same number of elements filled with a given value. For example, {% for var in variable|slice(4,'FILLER') %}{{var}}{% endfor %} outputs: ['C', 'a', 'p'],['u', 'c','FILLER'],['c', 'i','FILLER'], ['n', 'o','FILLER'].

  • batch.- The batch filter returns a batch of lists. For example, a variable that contains ["Capuccino"] the filter statement {% for var in variable|batch(4) %}{{var}}{% endfor %} outputs ['C', 'a', 'p', 'u'],['c', 'c', 'i', 'n'],['o']. It's possible to use the fill_with as a second argument -- which defaults to None -- so all segments contain the same number of elements filled with a given value. For example, {% for var in variable|slice(4,'FILLER') %}{{var}}{% endfor %} outputs: ['C', 'a', 'p', 'u'],['c', 'c', 'i', 'n'],['o','FILLER','FILLER','FILLER'].

  • sort.- The sort filter sorts elements by ascending order. For example, if a variable contains ['e','u','a','i','o'] the statement {{variable|sort}} outputs ['a','e','i','o','u']. It's possible to indicate descending order by setting the first argument to true (e.g. {{variable|sort(true)}} outputs ['u','o','i','e','a']). In addition, if a list is made up strings, a second argument can be used to indicate case sensitiveness -- which is disabled by default -- to perform the sort operation (e.g. {{variable|sort(true,true)}}). Finally, if a list is composed of objects, it's also possible to specify the sort operation on a given attribute (e.g. variable|sort(attribute='date') to sort the elements based on the date attribute).

  • unique.- The unique filter returns unique values. For example, if a variable contains ['Python','PYTHON','Python','JAVASCRIPT', 'JavaScript'] the statement {{variable|unique|list}} outputs ['Python','JAVASCRIPT']. By default, the unique filter is case insensitive and returns the first unique match it finds. It's possible to perfom case sensitive unique matching using the case_sensitive argument (e.g. {{variable|unique(case_sensitive=True)|list}} returns ['Python', 'PYTHON', 'JAVASCRIPT', 'JavaScript']).

Dictionaries and objects

  • dictsort.- The dictsort filter sorts a dictionary by key, case insensitive. For example, if a variable contains {'name':'Downtown','city':'San Diego','state':'CA'} the filter {% with newdict=variable|dictsort %} the newdict variable is assigned the dictionary {'city':'San Diego','name':'Downtown','state':'CA'}. In addition, the dictsort can accept three arguments: case_sensitive to indicate case sensitive/insensitive order, by to specify sorting by key or value and reverse to specify reverse ordering. The default dictsort behavior is case insensitive, sort by key and natural(provided) order (e.g. variable|dictsort). To alter the default dictsort behavior, you can assign: case_sensitive a True or False(Default) value; by a 'value' or 'key'(Default) value; and reverse a True or False(Default) value.

  • attr.- The attr filter returns the attribute of an object (e.g. {{coffeehouse.city}} outputs the city attribute value of the coffeehouse object). Note the attr filter only attempts to look up an attribute and not an item (e.g. if coffeehouse is a dictionary and city is a key item it won't be found). Alternatively, you can just use the standard Python syntax variable.name -- which first attempts to locate an attribute called name on variable, then the name item on variable or if nothing matches an undefined object is returned -- or variable['name'] -- which first attempts to locate the name item on variable, then an attribute called name on variable or if nothing matches an undefined object is returned.

  • rejectattr.- The rejectattr filter removes objects that don't contain an attribute or objects for which a certain attribute doesn't pass a test -- see bullets in this chapter section marked as (Test) for acceptable values. For example, {% for ch in coffeehouses|rejectattr("closedon") %} generates a loop for coffeehouse objects that don't have the closedon attribute or {% for u in users|rejectattr("email", "none") %} generates a loop for user objects that don't have email None -- note the second argument none represents the test.

  • selectattr.- The selectattr filter selects objects that contain an attribute or objects for which a certain attribute passes a test -- see bullets in this chapter section marked as (Test) for acceptable values. For example, {% for u in users|selectattr("superuser") %} generates a loop for user objects that have the superuser attribute or {% for u in users|selectattr("email", "none") %} generates a loop for user objects that have email None -- note the second argument none represents the test.

  • groupby.- The groupby filter is used to rearrange the contents of a list of dictionaries or objects into different group object sequences by a common attribute. Listing 4-20 illustrates an example of the groupby filter.

Listing 4-20. Jinja groupby filter

# Dictionary definition
stores = [
    {'name': 'Downtown', 'street': '385 Main Street', 'city': 'San Diego'},
    {'name': 'Uptown', 'street': '231 Highland Avenue', 'city': 'San Diego'},
    {'name': 'Midtown', 'street': '85 Balboa Street', 'city': 'San Diego'},
    {'name': 'Downtown', 'street': '639 Spring Street', 'city': 'Los Angeles'},
    {'name': 'Midtown', 'street': '1407 Broadway Street', 'city': 'Los Angeles'},
    {'name': 'Downton', 'street': '50 1st Street', 'city': 'San Francisco'},
]

<ul>
{% for group in stores|groupby('city') %}
    <li>{{ group.grouper }}
    <ul>
        {% for item in group.list %}
          <li>{{ item.name }}: {{ item.street }}</li>
        {% endfor %}
    </ul>
    </li>
{% endfor %}
</ul>

# Output
Los Angeles
    Downtown: 639 Spring Street
    Midtown: 1407 Broadway Street
San Diego
    Downtown : 385 Main Street
    Uptown : 231 Highland Avenue
    Midtown : 85 Balboa Street
San Francisco
    Downtown: 50 1st Street

# Alternate shortcut syntax, produces same output
<ul>
{% for grouper, list in stores|groupby('city') %}
    <li>{{ grouper }}
    <ul>
        {% for item in list %}
          <li>{{ item.name }}: {{ item.street }}</li>
        {% endfor %}
    </ul>
    </li>
{% endfor %}
</ul>
  • tojson.- The tojson filter outputs data structures to JavaScript Object Notation(JSON) (e.g.{{variable|tojson}}). The tojson filter accepts the indent argument -- which is set to None -- to generate pretty output by a given number of spaces (e.g. {{variable|tojson(indent=2)}}) generates output indented with two spaces).

Tip You can globally set options for the tojson filter through Jinja policies, described in the last section of this chapter.

Strings

  • capitalize.- The capitalize filter capitalizes the first character of a string variable. For example, if a variable contains hello world the filter statement {{variable|capitalize}} outputs Hello world.

  • list.- The list filter is used to return a list of characters. For example, if a variable contains latte the filter statement {{variable|list}} generates ['l','a','t','t','e'].

  • lower.- The lower filter converts all values of a string variable to lowercase. For example, if a variable contains Hello World the filter statement {{variable|lower}} outputs hello world.

  • lower (Test).- The lower test returns true if a variable is lower cased. For example, {% if variable is lower %}Yes, the variable is lowercase!{% endif %} outputs the statement if variable is lower cased

  • replace.- The replace filter works just like Python's standard replace string. The first argument is the sub-string that should be replaced, the second is the replacement string. If the optional third argument amount is given, only this amount of occurrences are replaced. For example {{ "Django 1.8"|replace("1.8", "1.9") }} outputs Django 1.9 and {{"oooh Django!"|replace("o", "",2) }} outputs oh Django!.

  • string.- The string filter makes a string unicode if it isn't already.

  • title.- The title filter converts all first character values of a string variable to uppercase. For example, if a variable contains hello world the filter statement {{variable|title}} outputs Hello World.

  • upper.- The upper filter converts all values of a string variable to uppercase. For example, if a variable contains Hello World the filter statement {{variable|upper}} outputs HELLO WORLD.

  • upper (Test).- The upper test returns true if a variable is upper cased. For example, {% if variable is upper %}Yes, the variable is uppercase!{% endif %} outputs the statement if variable is uppercase.

  • wordcount.- The wordcount filter counts the words in a string. For example, if a variable contains Coffeehouse started as a small store the filter statement {{variable|wordcount}} outputs 6.

Numbers

  • abs.- The abs return the absolute value of the number argument. For example, if a variable contains -5 the filter statement {{variable|abs}} outputs 5.

  • filesizeformat.-The filesizeformat filter converts a number of bytes into a friendly file size string. For example, if a variable contains 250 the filter statement {{variable|filesizeformat}} outputs 250 Bytes, if it contains 2048 the output is 2 kB, if it contains 2000000000 the output is 2.0 GB. By default, decimal prefixes are used (e.g. Giga, Mega, Kilo), if you pass an additional boolean parameter with true (e.g. {{variable|filesizeformat(true)}}) then binary prefixes are used (e.g. Gibi, Mebi, Kibi)

  • float.- The float filter converts a value into a floating-point number. If the conversion doesn't work it returns 0.0 or a custom value argument (e.g. variable|float("It didn't work") returns "It didn't work" if variable can't be converted to a floating-point number).

  • int.- The int filter converts a value into an integer. If the conversion doesn't work it returns 0 or a custom value specified as the first argument to the filter -- just like the float filter. You can also override the default base 10 with a second filter argument, which handles input with prefixes such as 0b, 0o and 0x for bases 2, 8 and 16 respectively (e.g. {{'0b001111'|int(0,2)}} a base 2 number outputs 15.

  • round.- The round filter rounds a number to a given precision, where the first argument is the precision -- which defaults to 0 -- and the second argument is a rounding method -- which defaults to 'common' rounding either up or down. For example, {{ 33.55|round }} assumes 'common' rounding to output 34.0). In addition to 'common', it's also possible to use 'ceil' to always round up or 'floor' to always round down (e.g. {{ 33.55|round(1,'floor') }} outputs 33.5). Note that even if rounded to the default 0 precision, a float is returned. If you need an integer you can apply the int filter (e.g. {{ 33.55|round|int }} outputs 34).

  • sum.- The sum filter returns the sum of a sequence of numbers, plus the value provided with the start parameter which defaults to 0. In addition, it's also possible to sum certain attributes of a list of objects {{ items|sum(attribute='price') }}.

  • divisibleby (Test).- The divisibleby test checks if a variable is divisible by a given number. For example, if a variable contains 20 the filter statement {% if variable is divisibleby(5) %}Variable is divisible by 5!{% endif %} outputs the conditional statement.

  • even (Test).- The even test checks if a number is even.

  • odd (Test).- The odd test checks if a number is odd.

Spacing and special characters

  • center.- The center filter center aligns a value and pads it with additional white space characters until it reaches the given argument of characters. For example, if a variable contains mocha the filter statement {{variable|center(width="15")}} outputs " mocha ".

  • escape or e.- The escape or e filter escapes HTML characters from a value. Specifically with the escape filter: < is converted to &lt;,> is converted to &gt;,' (single quote) is converted to &#39;," (double quote) is converted to &quot;, and & is converted to &amp.

  • escaped (Test).- The escaped test checks if a value is escaped.

  • forceescape.- The forceescape filter escapes HTML characters from a value just like the escape filter. The difference between both filters is the forceescape filter is applied immediately and returns a new and escaped string. This is useful in the rare cases where you need multiple escaping or want to apply other filters to the escaped results. Normally, you'll use the escape filter.

  • format.- The format filter is used to apply Python string formatting to a variable. For example, the statement {{ "%s and %s"|format("Python", "Django!") }} outputs Python and Django!.

  • indent.- The indent filter is used to output a string with each line except the first one indented with four spaces. It's possible to change the number of spaces and the indentation of the first line with additional filter arguments (e.g. {{ textvariable|indent(2, true) }} the 2 indicates two spaces and true indicates to indent the first line.

  • safe.- The safe filter marks a string as not requiring further HTML escaping. When this filter is used with an environment without automatic escaping it has no effect.

  • striptags.- The striptags filter removes all HTML tags from a value. For example, if a variable contains <b>Coffee</b>house, the <i>best</i> <span>drinks</span> the filter statement {{variable|striptags}} outputs Coffeehouse, the best drinks.

  • trim.- The trim filter is used to strip leading and trailing whitespace just like Python's string strip() method. By default, trim strips leading and trailing whitespace, but it's possible to strip specific characters by passing a string argument (e.g. variable|strip("#") strips leading and trailing # from variable).

  • truncate.- The truncate filter truncates a string to a given number of characters -- defaulting to 255 characters -- and appends an ellipsis sequence. For example, if a variable contains Coffeehouse started as a small store the filter statement {{variable|truncate(20)}} outputs Coffeehouse ..., keeping up until character number 20 and then discarding the last full word, finally adding the ellipsis. You can add true as a second argument so the string is cut at an exact length (e.g. {{variable|truncate(20,true)}} outputs Coffeehouse start... including the ellipsis characters). It's possible to provide a different symbol than an ellipsis passing a second parameter (e.g.{{variable|truncate(20,true,"!!!")}} would output !!! instead of an elipsis). And finally, the truncate filter accepts a fourth argument leeway to specify a string tolerance in characters -- which defaults to 5 -- to avoid truncating strings (e.g. this avoids truncating words with less than 5 characters).

Tip You can globally set the leeway value for the truncate filter through Jinja policies, described in the last section of this chapter.
  • wordwrap.- The wordwrap filter wraps words at a given character line length argument. By default, the wrapping occurs after 79 characters which can be overridden providing a first argument with the number of characters. If you set a second parameter to false, Jinja does not split words longer than the wrapping character length. In addition, wrapping generates a newline character as defined in the environment -- generally the \n character -- but this can be changed by specifying the wrapstring keyword argument (e.g. {{variable|wordwrap(40,true,'-') uses a hyphen as the wrapping newline character). Finally, a fourth argument can be passed to the wordwrap filter to indicate if breaks should be applied on hyphens, which by default is true, it's helpful to set this option to false when dealing with long words that have hyphens that shouldn't wrap (e.g. site urls). Listing 4-21 illustrates an example of the wordwrap filter.

Listing 4-21. Jinja wordwrap filter

# Variable definition 
Coffeehouse started as a small store

# Template definition with wordwrap filter for every 12 characters
{{variable|wordwrap(12)}}

# Output
Coffeehouse 
started as a
small store
  • xmlattr.- The xmlattr filter is used to create an SGML/XML attribute string based on the items in a dictionary or object. Once you create a dictionary structure containing attribute names and reference values, you pass it through the xmlattr filter to generate the attribute string. By default, all values that are neither none or undefined are automatically escaped, but you can override this behavior by passing false as the first filter argument. Listing 4-22 illustrates an example of the xmlattr filter.

Listing 4-22. Django xmlattr filter

# Variable definition 
{% set stores = [
    {'id':123,'name': 'Downtown', 'street': '385 Main Street', 'city': 'San Diego'},
    {'id':243,'name': 'Uptown', 'street': '231 Highland Avenue', 'city': 'San Diego'},
    {'id':357,'name': 'Midtown', 'street': '85 Balboa Street', 'city': 'San Diego'},
    {'id':478,'name': 'Downtown', 'street': '639 Spring Street', 'city': 'Los Angeles'},
    {'id':529,'name': 'Midtown', 'street': '1407 Broadway Street', 'city': 'Los Angeles'},
    {'id':653,'name': 'Downton', 'street': '50 1st Street', 'city': 'San Francisco'},
] %}

# Template definition
<ul>
{% for store in stores %}
  <li {{ {'id':'%d'|format(store.id),'class':'%s'|format(store.city|lower|replace(' ','-')) }|xmlattr }}>
               {{store.city}} {{store.name}}
  </li>
{% endfor %}
</ul>

# Output
<ul>
  <li id="123" class="san-diego"> San Diego Downtown</li>
  <li id="243" class="san-diego"> San Diego Uptown</li>
  <li id="357" class="san-diego"> San Diego Midtown</li>
  <li id="478" class="los-angeles"> Los Angeles Downtown</li>
  <li id="529" class="los-angeles"> Los Angeles Midtown</li>
  <li id="653" class="san-francisco"> San Francisco Downton</li>
</ul>

Development and testing

  • pprint.- The pprint filter is a wrapper for Python's pprint.pprint(). The pprint filter is useful during development and testing because it outputs the formatted representation of an object. By default, the pprint filter is not verbose but you can make it verbose passing it the true argument (e.g. {{variable|pprint(true)}}).

Urls

  • urlencode.- The urlencode filter escapes a value for use in a URL. For example, if a variable contains http://localhost/drinks?type=cold&size=large the filter statement {{variable|urlencode}} outputs http%3A//localhost/drinks%3Ftype%3Dcold%26size%3Dlarge.

  • urlize.- The urlize filter converts text URLs into clickable HTML links. You can pass the filter an additional integer to shorten the visible url (e.g. {{ variable|urlize(40)}} links are shortened to 40 characters plus an ellipsis). It's also possible to add a second argument as a boolean to make the urls "nofollow" (e.g. {{ variable|urlize(40, true)}} links are shortened to 40 characters and defined with rel="nofollow"). Finally, it's also possible to add the target argument to define a link target (e.g.{{ variable|urlize(40, target="_blank")}} links are shortened to 40 characters and open in a new window).

Sunday, November 17, 2024

Saturday, November 9, 2024

Open-source Free English Dictionary


1- List Of English Words (479k Words)

This repo offers a text file containing 479k English words for all your dictionary/word-based projects e.g: auto-completion / autosuggestion. The data comes in JSON format, and in text format. It also offers an example as in Python script.

GitHub - dwyl/english-words: :memo: A text file containing 479k English words for all your dictionary/word-based projects e.g: auto-completion / autosuggestion
:memo: A text file containing 479k English words for all your dictionary/word-based projects e.g: auto-completion / autosuggestion - GitHub - dwyl/english-words: :memo: A text file containing 479k…

2- Open-Source English Dictionary (176,023 definitions)

An open source English language dictionary with 176,023 definitions.

This is based on the Source Forge Project: MySQL English Dictionary , which in turn in based on the The Online Plain Text English Dictionary (OPTED) dictionary.

OPTED is a public domain English word list dictionary, based on the public domain portion of "The Project Gutenberg e-text of Webster's Unabridged Dictionary" which is in turn based on the 1913 US Webster's Unabridged Dictionary.




3- List of the Most Common English Words

The Unix dictionary contains far too many ridiculous words that even Google has trouble explaining, such as zuurveldt, cholecystenterorrhaphy and nonly:

$ cat /usr/share/dict/words | wc -l
235886
GitHub - dolph/dictionary: A list of the most popular English words.
A list of the most popular English words. Contribute to dolph/dictionary development by creating an account on GitHub.

4- wiktionary-dict



This project collects bilingual Wiktionary dictionaries in DSL-format, based on the work of Wiktionary User:Matthias_Buchmeier.

The scripts used to convert these dictionaries can be found here, and the original source files and other information can be found on the project homepage on Wiktionary.

GitHub - open-dsl-dict/wiktionary-dict: Offline bilingual dictionaries made using data from Wiktionary
Offline bilingual dictionaries made using data from Wiktionary - GitHub - open-dsl-dict/wiktionary-dict: Offline bilingual dictionaries made using data from Wiktionary

5- ipa-dict - Monolingual word lists with pronunciation information in IPA

This project aims to provide a series of dictionaries consisting of wordlists with accompanying phonemic pronunciation information in International Phonetic Alphabet (IPA) transcription for as many words as possible in as many languages / dialects / variants as possible.

Supported formats include: Raw data, JSON, CSV, XML and several other formats.

The included languages are: Arabic, German, Esperanto, Finish, Japanese, Khmer, Korea, Dutch, French, Persian, Romanian, Swedish, and many more.

GitHub - open-dict-data/ipa-dict: Monolingual wordlists with pronunciation information in IPA
Monolingual wordlists with pronunciation information in IPA - GitHub - open-dict-data/ipa-dict: Monolingual wordlists with pronunciation information in IPA

6- Syng: Chinese To English




Syng is a free, cross-platform, open-source, Chinese-To-English and English-To-Chinese dictionary. Syng is your study assistant to help you learn Chinese no matter where you are in your journey.

Syng v2 is now in beta. Please be patient as features get ported over from v1. In addition to a new interface, Syng v2 includes numerous under-the-hood enhancements on top of v1 that enable the possibility of more advanced features.

GitHub - sotch-pr35mac/syng: A free, open source, cross-platform, Chinese-To-English dictionary for desktops.
A free, open source, cross-platform, Chinese-To-English dictionary for desktops. - GitHub - sotch-pr35mac/syng: A free, open source, cross-platform, Chinese-To-English dictionary for desktops.

7- Simple Dictionary



An offline English to English dictionary with spell suggestions using the open source dictionary data. It is built on top of Java, and comes with HTML interface.

GitHub - subhashnottath/dictionary: An offline English to English dictionary with spell suggestions using the open source dictionary data
An offline English to English dictionary with spell suggestions using the open source dictionary data - GitHub - subhashnottath/dictionary: An offline English to English dictionary with spell sugge…

8- Saladict (Google Chrome, and Mozilla Firefox)


Saladict is an all-in-one professional pop-up dictionary and page translator. It supports mixed use of multiple search modes.

Saladict
Saladict is an all-in-one professional pop-up dictionary and page translator which supports multiple search modes, page translations, new word notebook and PDF selection searching.

9- FreeDict

The FreeDict project strives to be the most comprehensive source of truly free bilingual dictionaries. They are not just free of charge, but they give you the right to study, change and modify them, as long as you guarantee others these freedoms, too. FreeDict nowadays provides over 140 dictionaries in about 45 languages and thanks to its members, grows continuously.

FreeDict is avaiable to download for Windows, and GNU/ Linux.

Home — FreeDict

10- Dictionary API

A Free headless Dictionary API for developers.  The API usage has been ramping up rapidly, making it difficult for me to keep the server running due to increased AWS costs.

GitHub - meetDeveloper/freeDictionaryAPI: There was no free Dictionary API on the web when I wanted one for my friend, so I created one.
There was no free Dictionary API on the web when I wanted one for my friend, so I created one. - GitHub - meetDeveloper/freeDictionaryAPI: There was no free Dictionary API on the web when I wanted…

11- English Dictionary (Android)

An open-source free English dictionary for Android, written in Java. It features word search, TextToSpeech option, SQLite database backend, and Search History.

GitHub - ardakazanci/English-Dictionary: English Dictionary Android Mobile App
English Dictionary Android Mobile App. Contribute to ardakazanci/English-Dictionary development by creating an account on GitHub.

12- En Dictionary

A Web App Dictionary For Getting Word's Meaning / Examples / Pronounciation Using cam-dict. It is an open-source free project that is released under the MIT license.

GitHub - hadiazt/En-Dictionary: English To English Word Meaning and etc. Dictionary
English To English Word Meaning and etc. Dictionary - GitHub - hadiazt/En-Dictionary: English To English Word Meaning and etc. Dictionary

13- English Idioms for Italian and Spanish People

A collection of the most common English idioms with their related Italian and Spanish translation.

GitHub - tsumarios/English-Idioms: A collection of the most common English idioms with their related Italian and Spanish translation.
A collection of the most common English idioms with their related Italian and Spanish translation. - GitHub - tsumarios/English-Idioms: A collection of the most common English idioms with their rel…

14- Russian English dictionary

A dynamic web application of English-Russian dictionary with accessibility. Built with React and Skyeng API. I built this project to improve my understanding of React and Redux.

GitHub - domoratskii/english-dictionary: A dynamic web application of English-Russian dictionary with accessibility. Built with React and Skyeng API
A dynamic web application of English-Russian dictionary with accessibility. Built with React and Skyeng API - GitHub - domoratskii/english-dictionary: A dynamic web application of English-Russian d…

15- Mercury (iOS)

Mercury is a free iOS English dictionary.

GitHub - SkullMag/Mercury: Mercury is a free iOS English dictionary
Mercury is a free iOS English dictionary. Contribute to SkullMag/Mercury development by creating an account on GitHub.

16- Dictionary (Vietnamese and Japanese)

This is a responsive single-page-app dictionary using Angular and Bootstrap. Currently, it supports English-Vietnamese dictionary and going to support Japanese-Vietnamese dictionary.

GitHub - hoaftq/Dictionary: A dictionary web app with data automatically collected from other pages
A dictionary web app with data automatically collected from other pages - GitHub - hoaftq/Dictionary: A dictionary web app with data automatically collected from other pages


17- Acron (Qt)

Acorn is a lightweight and responsive English Dictionary application using the cross-platform Qt toolkit for its interface.

GitHub - jayzsh/Acorn: Acorn is a lightweight and responsive English dictionary app using Princeton’s WordNet lexical database and the Qt5 toolkit
Acorn is a lightweight and responsive English dictionary app using Princeton&#39;s WordNet lexical database and the Qt5 toolkit - GitHub - jayzsh/Acorn: Acorn is a lightweight and responsive Engli…

18- Web English dictionary app

English dictionary app using HTML, CSS, and JS.

GitHub - Koshyar-r/dictionary-app: English dictionary app using HTML, CSS and JS.
English dictionary app using HTML, CSS and JS. Contribute to Koshyar-r/dictionary-app development by creating an account on GitHub.

19- Open-source Dictionary for Firefox

GitHub - JonasHogman/firefox-dictionary: WebExtension for Firefox that provides Google Dictionary for Chrome-like functionality (except prettier and with more bugs).
WebExtension for Firefox that provides Google Dictionary for Chrome-like functionality (except prettier and with more bugs). - GitHub - JonasHogman/firefox-dictionary: WebExtension for Firefox that…

  • UKACD (UK Advanced Cryptics Dictionary), about 250000 words, is good for crossword setting and solving
  • YAWL (Yet Another Word List), about 250000 words, is a copyright-free American list popular among Unix users
  • Moby, about 600000 words, is part of Project Gutenberg
  • ABLE (Alternate British LExicon), 200000 words, is a UK-oriented list designed for word puzzles
  • SOWPODS, about 270000 words, is a standard word list used for Scrabble and other word games all over the world
  • TWL, about 180000 words, is a standard word list used for Scrabble and other word games in the United States and elsewhere
  • PDL, a public domain word list originally called PUBLIC.DICT.LARGE containing about 37000 reasonably common words with a slight academic bias
  • BNC, a word list derived from the British National Corpus containing about 470000 strings, the great majority of which are words
  • Broda, a list of about 390000 words aimed at US puzzlers

Thursday, October 24, 2024

Python Code for Google Search Autocomplete Suggestions

import requests

headers = {
    'accept': '*/*',
    'accept-language': 'en-US,en;q=0.9,de;q=0.8,ro;q=0.7',
    'cache-control': 'no-cache',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://www.google.com/',
    'sec-ch-prefers-color-scheme': 'light',
    'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
    'sec-ch-ua-arch': '""',
    'sec-ch-ua-bitness': '"64"',
    'sec-ch-ua-form-factors': '',
    'sec-ch-ua-full-version': '"129.0.6668.71"',
    'sec-ch-ua-full-version-list': '"Google Chrome";v="129.0.6668.71", "Not=A?Brand";v="8.0.0.0", "Chromium";v="129.0.6668.71"',
    'sec-ch-ua-mobile': '?1',
    'sec-ch-ua-model': '"Nexus 5"',
    'sec-ch-ua-platform': '"Android"',
    'sec-ch-ua-platform-version': '"6.0"',
    'sec-ch-ua-wow64': '?1',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36',
}

params = {
    'q': 'Tiberiu Cristian Leon',
    'cp': '10',
    # 'client': 'mobile-gws-wiz-serp',
    'client': 'chrome',
    'hl': 'en-RO',
    'authuser': '0',
}

response = requests.get('http://google.com/complete/search', headers=headers, params=params)
print(', '.join(response.json()[1]))

15 Windows Features

 

1. Get Computer Help From Anywhere

This one is known to most veteran Windows users. The Remote Assistance feature allows you to send an invitation to your favorite computer person. Then they can log on to your computer remotely, to help you solve a problem.

remote-assistance

It's safe, don't worry. Their ability to connect is temporary. You can even decide whether they just see your desktop or can interact with it.

All this time you've been relying on TeamViewer or LogMeIn. If you do ask your favorite IT person for help, make sure you take good care of them in return. You can turn on Remote Assistance in Control Panel > System > Advanced System Settings > Remote.

2. All In One Calculator

You know there's a calculator app in Windows. But did you know that it's really several calculators? It's your basic calculator, but it's also scientific, programmer, and statistics calculators. Seriously. And like any good multi-tool…wait, there's more!

calculator-functions

You can do unit conversion like inches to centimeters. You can figure out how many days you've been alive with date calculation. It'd be a bargain if we stopped there, but we won't!

Did you know that it can do things you thought only spreadsheets like Excel could? How about mortgage and leasing calculation worksheets? Use it to figure out how fuel efficient your car is - in miles per gallon AND liters per 100 kilometers. Whatever a liter is, pfft.

3. Clean Bloatware and Fix Windows Quickly

Deployment Imaging Service and Management (DISM) is a very powerful utility. We've covered how you can use DISM to quickly get rid of bloat and crap ware in Windows 10, but it can do so much more.

You can use it to capture an image of a hard drive partition, maybe to back up your computer. You can even use it to repair your Windows, without the recovery disks.

DISM

Just look above  at the help file on it. This may look like a foreign language to you, but if you're willing to take the time to learn it, you might surprise yourself. You might find you can use this tool for things you never thought possible.

DISM is accessed by opening an elevated command prompt window (with Admin rights) and using the DISM command.

4. Move Everything From Your Old to New Computer

When you get a new computer, the most tedious job is transferring all your files and Windows settings. That's where Windows Easy Transfer makes your life, well, easier.

windows-easy-transfer

Easy Transfer will move all your files and folders from the Pictures, Music, Documents, and Shared Documents folders. You can also select files and folders from other locations. It can transfer your e-mail settings, messages and contacts. It will even preserve all your special settings that make Windows just the way you like it.

On Windows 7 or 8.1, just click on your Start button and search for "easy transfer". Windows 10 users can use features available through the native Settings app and OneDrive to sync data or use third party tools to move Windows settings and apps or backup and sync files.

5. Send and Receive Faxes Without a Fax Machine

Faxing may seem a little old fashioned to you. But faxes still have a place in this world, and the Windows Fax and Scan utility can help. It can let you use your computer to send and receive faxes. You can also use it to print, e-mail, and save and organize faxes.

fax-scan

Now keep in mind, you do need a fax modem for this to work. You might have to break into a museum to get one, though. It's odd, but it is there, and you might need it, but not know about it.

Windows Fax and Scan can be found by going to your Start menu and searching on "fax and scan"; even in Windows 10!

6. Test Drive Other Operating Systems

You can create a virtual computer, or virtual machine as they're called, on your Windows computer. On that virtual machine you can install different operating systems. In Windows, the tool for this is Hyper-V.

hyper-v

Want to test drive Linux? Hyper-V. Want to try Windows 10? Hyper-V. Everything that happens on your virtual machine never affects your physical computer. It's your computer playground.

To install Hyper-V go to Control Panel > Programs and Features > Turn Windows features on or off. You'll find it in there.

7. Set Up a Web Server

All the web sites you know and love reside on web servers. Did you know Windows comes with one built in. It's called Internet Information Services (IIS).

Now, you might not want to use your home computer to host your business' website, but if you want to play around, learn some web programming, and see what makes web sites and servers tick, IIS is a powerful, and free, tool in Windows.

IIS8

IIS also comes with a File Transfer Protocol (FTP) server. If you don't know what an FTP server does, it can be used as a place to host pretty much any kind of file. Then, using an FTP client you can connect to your FTP server from any where in the world and down load your files. You could even use it to host files for family near and far. Think of hosting family photo albums or videos, maybe useful documents or programs.

IIS is also installed from  Control Panel > Programs and Features > Turn Windows features on or off.

8. Make That Weird Character

Ever been typing an e-mail or a school report and you need to make a character that isn't on the keyboard? Maybe you want to make the copyright sign, or a subscript 1 on a footnote. Maybe you need some astrological or electrical symbols. How about a dipthong or an umlaut? What are those, even? Who knows?

Well you do, and Windows Character Map is a good way to get them. To open it up, go to your Start menu and search for charmap or character map.

character-map

Once it's open, scroll through it, change to many other fonts even. Then just copy and paste. Or look at the bottom of the window for the Alt code.

Each character has it's own little code. Hold down your Alt key, type the plus sign on your number pad and then the code for the character. When you release the Alt key, your special character will appear. This works in most Windows-based programs.

9. Get Better Monitor Color

It's not professional photographer grade monitor calibration, yet the Windows Calibrate Display Color utility can make your viewing experience much more pleasurable.

color-calibration

Maybe you're a gamer and your character doesn't look right. Maybe you like to edit family photos, but they don't look the same on the screen as your originals. Maybe you just want to have great color represented on your display.

The Calibrate Display Color utility can help with that. And you already own it. It's in your Control Panel under Display and you can find it when searching from the Start menu.

10. Talk to and Listen to Windows

If you read our article on making Windows easier to use if nearsighted or farsighted, you know that you can make Windows talk to you.

Windows Narrator will read to you what's on your screen. Using keyboard shortcuts, you can make Narrator read the entire selected window, an entire document, or even just a page, paragraph, line, or word.

speech-recognition

This can be quite helpful for people with visual impairments. But you might use it if you're suffering from Computer Vision Syndrome, or just sick of looking at a screen. To start Narrator, open your Start menu, search for narrator and open the correct result.

Of course, if Windows can talk to you, it should be able to listen, too. Windows 10 users will know all about Cortana, but Windows has been able to hear you for a while now. Windows Speech Recognition goes way back to the Vista days.

It might not speak back to you like Cortana, but you can use Windows Speech Recognition to do just about anything. Setting it up is easy and takes less than a minute. The commands are simple, make sense, and are easy to remember. You can open and close programs, dictate letters, and find and open files. That's just a very small look into what Windows Speech Recognition can do. Open your Start menu and search for speech recognition (not available on Windows 10).

11. Hands Off!

This handy feature was buried in the Food and Drink app back in Windows 8.1. It was there for a good reason, though.

Let's say you had your favorite recipe open on your laptop or tablet, making a feast. You needed to go to the next page but your hands were covered in butter or dough. Oh no! Don't worry, just wave your hand in front of the webcam and Windows would turn the page for you.

npointer

That's a good thing. The bad thing is that the Food and Drink app was discontinued. But you can easily get an app like NPointer, so you can control your computer like it's a Jedi mind trick.

ReadyBoost was added back in Vista, and was a bit of a flop. Some folks had a hard time getting it working, but most people didn't even know it existed. It has been refined and improved over time and now may be of great use to you. Simply, it allows you to use external memory, like a USB flash drive or an SD card, as a sort of RAM.

ready-boost

As of Windows 10, it can use ALL the flash drives that are connected to your computer. So, if your computer only has 8 GB of RAM, you could pop in an 8 GB USB flash drive and double your RAM.

In Windows Explorer, right-click on the USB drive you'd like to use, select Properties, then click on the ReadyBoost tab and follow the instructions. Nice trick, Windows.

13. Project a Really Long Distance

Network Projection is a feature that allows you to connect to a projector over your network. Provided, of course, that your projector also connects to the network. It might not be something that you'll use with your projector at home, but this little trick might make you the star of the next board meeting.

connect-to-network-projector

Instead of having to plug a video cable into the projector and have it dangling down to your laptop, just plug in to the network, connect via Network Projection and be a presentation pro.

Unfortunately, this feature appears to have been removed for Windows 10, but is still available in Windows 7, 8, and 8.1. From your Start menu, search for Connect to a network projector to find it.

14. Make Your PC a Video Star

New for Windows 10 is the Game DVR (Digital Video Recorder) utility. This one does require you to have the Xbox app for Windows 10 installed. Intended to be used by gamers to make video clips of their exploits, there's no reason you can't use it to record whatever you want.

xbox recording

Press the Windows key + G to launch the Game DVR. It will ask you if this is your gaming machine. Click yes, we won't tell on you. Then you'll see the controls to start recording. It'll even allow you to do some minor editing, like trimming the video length.

15. Show Your IT Person What You Were Doing

This is the one that even good PC techs might not know about. Using Windows Steps Recorder, you can provide a detailed list of everything you did right up to, and including, the point where your problem began.

windows-steps-recorder

The Steps Recorder will pack the recorded steps up in a nice little zip file that you can email to your favorite tech. They can open it and try to pinpoint exactly where things went wrong. That will help them give you the best solution that they can.

To start Step Recorder, search for steps recorder from your Start menu. It should be the first result.

Note that it will NOT record your passwords. So if you have to open a file with a password, you can safely record the steps. Your tech will not be able to get your password from Windows Steps Recorder. This trusty tool could really make your life easier, especially if you're the de facto IT person for the office or family.