Skip to content

Instantly share code, notes, and snippets.

View Luxato's full-sized avatar
🎯
Focusing

Lukas S. Luxato

🎯
Focusing
  • Denmark
View GitHub Profile
@Luxato
Luxato / camera.py
Last active April 23, 2024 06:34
Take picture from USB camera with python
import cv2
import imutils
import time
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
def takePicture():
(grabbed, frame) = cap.read()
showimg = frame
@Luxato
Luxato / notebook.py
Created April 19, 2018 08:43
Install pip package in Jupyter notebook
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
@Luxato
Luxato / get_all_files_in_dir.php
Last active April 20, 2018 07:35
Get all the files and directories recursively.
<?php
/**
* Get all the files and directories recursively.
*
* @param $dir
* @param array $results
*
* @return array
*/
function getDirContents( $dir, &$results = array() ) {
@Luxato
Luxato / install.php
Created April 20, 2018 07:34
Magento installer default boilerplate.
<?php
/*
* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
*/
$installer = $this;
$installer->startSetup();
$connection = $installer->getConnection();
$connection->beginTransaction();
try {
@Luxato
Luxato / permission.bat
Created April 30, 2018 11:09
Windows - equivalent to chmod -R 777
icacls "L:\AAU\Semester 8th\CLAAS DATA\recordings" /grant everyone:f /t
@Luxato
Luxato / list_files_in_dir.py
Created May 1, 2018 19:47
Read files in directory with python
import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join
directory = os.fsencode(dir_in_string)
for file in os.listdir(directory):
filename = os.fsdecode(file)
@Luxato
Luxato / get_weight.php
Created May 2, 2018 12:47
Magento get weight of whole cart
<?php
$weight = Mage::getSingleton('checkout/session')
->getQuote()
->getShippingAddress()
->getWeight();
@Luxato
Luxato / validate.js
Created June 8, 2018 07:36
Javascript regular expression for validating emails
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
@Luxato
Luxato / convert_png_to_jpg.py
Created October 5, 2018 16:01
Convert .png images into .jpg with python3
import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join
from PIL import Image
source_dir = "C:\\Users\\Lukas\\Desktop\\KITTI dataset\\left_camera\\VOC2012\\JPEGImages"
directory = os.fsencode(source_dir)
@Luxato
Luxato / magento1_ajax.js
Last active October 25, 2018 10:22
Magento 1 send ajax request.
new Ajax.Request("<?= Mage::helper('adminhtml')->getUrl('adminhtml/password/securitycheck') ?>", {
method: 'POST',
parameters: {'password': password},
requestHeaders: {Accept: 'application/json'},
onSuccess: function(response){
// Parse text as JSON
response = JSON.parse(response.responseText);
// Redirect
window.location.href = deleteURL;
}