Skip to content

Instantly share code, notes, and snippets.

View oscarolar's full-sized avatar

Olar Alca [Vauxoo] oscarolar

View GitHub Profile
@oscarolar
oscarolar / bootable-win-on-mac.md
Created August 14, 2024 16:11 — forked from acarril/bootable-win-on-mac.md
Create a bootable Windows USB using macOS

For some reason, it is surprisingly hard to create a bootable Windows USB using macOS. These are my steps for doing so, which have worked for me in macOS Monterey (12.6.1) for Windows 10 and 11. After following these steps, you should have a bootable Windows USB drive.

1. Download a Windows disc image (i.e. ISO file)

You can download Windows 10 or Windows 11 directly from Microsoft.

2. Identify your USB drive

After plugging the drive to your machine, identify the name of the USB device using diskutil list, which should return an output like the one below. In my case, the correct disk name is disk2.

@oscarolar
oscarolar / darwin.py
Last active February 1, 2024 19:32
darwin.py
def is_leap_year(year):
"""
Check if a year is a leap year.
"""
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
def day_of_year(year, month, day):
"""
Returns the day of the year for a given date.
Returns None if any of the arguments is invalid.
@oscarolar
oscarolar / gist:822eb3e2ca21c979c0b46af737217a98
Created March 11, 2022 15:33 — forked from jayswan/gist:a8d9920ef74516a02fe1
Elasticsearch Python bulk index API example
>>> import itertools
>>> import string
>>> from elasticsearch import Elasticsearch,helpers
es = Elasticsearch()
>>> # k is a generator expression that produces
... # a series of dictionaries containing test data.
... # The test data are just letter permutations
... # created with itertools.permutations.
... #
... # We then reference k as the iterator that's
import psycopg2, json
conn = psycopg2.connect("dbname=dbname user=user password=pass")
cr = conn.cursor()
filename = "linkedin.json"
file = open(filename, 'r')
for line in file:
string_query = """('%s')""" % (str(line).replace("'", ""))
query = """
INSERT INTO linkedin (info)
VALUES %s;
@oscarolar
oscarolar / return_action.py
Created August 1, 2017 20:51
Return action
@api.multi
def button_whatever(self):
self.ensure_one()
return { 'name': 'My Name',
'type': 'ir.actions.act_window',
'views':[[False,'form']],
'res_model': 'my.custom.model',
'target': 'new',
'context': {'default_my_type':'state','default_model_id':self.id} }
@oscarolar
oscarolar / bundles.xml
Created July 27, 2017 17:35
Bundles Kathy
<t t-foreach="product_template.product_variant_ids" t-as="variant">
<button t-att-style="'display:none' if product.template.product_variant_ids[0].id != variant.id else ''" class="btn btn-danger modal-toggler" t-att-data-variant-id="variant.id" data-toggle="modal" t-att-data-target="'#modal_bundles_%s' % (variant.id)"></button> <!-- data-target="#modal_bundles_1"-->
<div t-att-id="modal_bundles_%s" % (variant.id) class="modal-body"></div> <!--style="display:none;"-->
</t>
<script>
$(oe_website_sale).on('change', 'input.js_variant_change, select.js_variant_change, ul[data-attribute_value_ids]', function (ev) {
var id = $(this).val(),
$button_to_show = $('button[data-variant-id="+id+"]');
$button_to_show.show();
var $buttons_to_hide = $('button.modal-toggler').without($button_to_show); //can be .without() or can be .not()
@oscarolar
oscarolar / addorreplaceattr.xml
Created July 25, 2017 01:50
Add or replace attr xml
<xpath expr="//p[@t-field='doc.note']" position="attributes">
<attribute name="t-raw" add="doc.note" separator=" " remove="t-field"/>
</xpath>
@oscarolar
oscarolar / list_magazine
Last active July 24, 2017 17:12
list magazine
<template>
<t t-set="cover_products" t-value="products[0:3]"/>
<t t-set="pages_products t-value="products[3:]">
<div class="magazine-cover">
<div class="magazine-header">img</div>
<div class="category-title" t-att-style="'background-image: url(/web/image/%s/%s/%s)' % (category.__name__, category.id, category.image)">
<h1 t-field="category.name"></h1>
</div>
<t t-foreach="cover_products" t-as="c_product">
<div class="magazine-banner"><img class="blue-bg" t-att-src="c_product.image"></img></div>
@oscarolar
oscarolar / popandnewyoytec.py
Created January 8, 2016 13:39
Popular and new products of yoytec by category.
@api.model
def _get_newest(self, limit, category=None):
"""
This method gets the higest newest products created on the instance.
:param int limit: maximum number of records to return.
"""
if category:
#extra logic to filter products by category.
published_products = self.search([('website_published', '=', True)],