Skip to content

Instantly share code, notes, and snippets.

View tejastank's full-sized avatar

Tejas Tank tejastank

View GitHub Profile
@danmana
danmana / example_model.py
Created August 16, 2021 15:08
Add support for custom json fields in Odoo
from odoo import models, fields, api
from json_field import JsonField
class Person(models.Model):
_name = 'example.person'
_description = 'Person with json details'
details = JsonField() # a json object represented as dict / list / python primitives
@fevangelou
fevangelou / Software RAID 1 setup on Ubuntu Server 20.04.md
Last active June 2, 2024 10:16
Software RAID 1 setup on Ubuntu Server 20.04 (or newer)

Looking to create a Software RAID 1 setup for your 2-disk server on Ubuntu Server 20.04?

Screen Shot 2020-06-05 at 20 55 31

Let's start with the basics: the official guide by Ubuntu (https://ubuntu.com/server/docs/install/storage) is outdated/wrong. And as of March 2021 it's possible that there's a bug as well with how the bios_grub partitions are created when using multiple disks.

Now on to the solution:

  • Select "Custom storage layout" when you reach the storage configuration step of the installer.
  • If the disks have existing partitions, click on each disk under AVAILABLE DEVICES and then select REFORMAT. This will (temporarily) wipe out the partitions.
import pickle as pk
import cv2
from pickle import dump
import os
import dlib
import face_recognition
import numpy as np
import time
path = os.path.dirname(os.path.abspath(__file__))
@smellslikeml
smellslikeml / yt_download.py
Last active June 21, 2024 12:35
download youtube videos to .mp4 with command line argument search string
#!/usr/bin/env python
import os
import sys
import requests
from bs4 import BeautifulSoup as bs
from urllib.parse import urlencode
from pytube import YouTube
qstring = sys.argv[1]
out_dir = sys.argv[2]
@tanaikech
tanaikech / submit.md
Last active January 29, 2024 01:17
Uploading Files From Local To Google Drive by Python without Quickstart

Uploading Files From Local To Google Drive by Python without Quickstart

This is a sample script for uploading files from local PC to Google Drive using Python. In this sample, Quickstart is not used. So when you use this script, please retrieve access token.

Curl sample :

curl -X POST \
    -H "Authorization: Bearer ### access token ###" \
    -F "metadata={name : 'sample.png', parents: ['### folder ID ###']};type=application/json;charset=UTF-8" \
    -F "file=@sample.png;type=image/png" \
 "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"
@jacobovidal
jacobovidal / .htaccess
Last active July 2, 2023 22:31
Upgrade Insecure Requests via .htaccess or meta tag to prevent mixed content
<ifModule mod_headers.c>
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import NumericProperty
from kivy.uix.widget import Widget
from kivy.clock import Clock
KV = '''
#:import degrees math.degrees
#:import sin math.sin
class TouchRippleBehavior(object):
ripple_rad = NumericProperty(10)
ripple_pos = ListProperty([0, 0])
ripple_color = ListProperty((0., 0., 0., 1.))
ripple_duration_in = NumericProperty(.4)
ripple_duration_out = NumericProperty(.4)
fade_to_alpha = NumericProperty(.12)
ripple_scale = NumericProperty(4.0)
ripple_func_in = StringProperty('in_cubic')
ripple_func_out = StringProperty('out_quad')
@alexcasalboni
alexcasalboni / amazon-rekognition.md
Last active September 6, 2023 15:20
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@jangnezda
jangnezda / main.js
Created October 12, 2016 11:44
How to load an external URL in <iframe> using Electron
/*
* By default, Electron (well, underlying Chrome browser) will reject loading external URLs
* to an <iframe>. To circumvent this limitation, we can manipulate response headers from any
* http request and feed them to the Electron window.
*
* The 'onHeadersReceived' listener is documented here:
* http://electron.atom.io/docs/api/session/#webrequestonheadersreceivedfilter-listener
*/
app.on('ready', () => {