Skip to content

Instantly share code, notes, and snippets.

View JEuler's full-sized avatar
🍉

Ivan Terekhin JEuler

🍉
View GitHub Profile
@JEuler
JEuler / extract.py
Created March 4, 2024 13:49
Extract .jpg files from folders in some current folder.
import os
import shutil
def extract_jpg_files(root_folder):
for root, dirs, files in os.walk(root_folder):
for file in files:
if file.endswith('.jpg'):
source_path = os.path.join(root, file)
destination_path = os.path.join(root_folder, file)
shutil.move(source_path, destination_path)
@JEuler
JEuler / screenshot.gd
Created August 15, 2023 09:34 — forked from jotson/screenshot.gd
Godot GDScript screenshot function
# This is a function for capturing screenshots with GDScript
func screenshot():
# Capture the screenshot
var size = OS.window_size
var image = get_viewport().get_texture().get_data()
# Setup path and screenshot filename
var date = OS.get_datetime()
var path = "user://screenshots"
var file_name = "screenshot-%d-%02d-%02dT%02d:%02d:%02d" % [date.year, date.month, date.day, date.hour, date.minute, date.second]
@JEuler
JEuler / Screenshooter.cs
Created July 22, 2023 10:50
Unity Screenshooter
public class ScreenShooter : MonoBehaviour {
private int _count = 0;
// Update is called once per frame
private void Update() {
if ( Input.GetKeyDown( KeyCode.S ) ) {
while ( System.IO.File.Exists( "ScreenShot_" + _count + "_" + Screen.width + "x" + Screen.height + ".png" ) ) {
_count++;
}
ScreenCapture.CaptureScreenshot( "ScreenShot_" + _count + "_" + Screen.width + "x" + Screen.height + ".png" );
}
void main() {
final configuredApp = AppConfig(
appName: 'App',
flavorName: 'uat',
apiBaseUrl: uatServerUrl,
coreAppBaseUrl: uatServerCoreUrl,
child: App(
WebService.create(uatServerUrl),
StorageServiceImpl(),
CoreAppWebService.create(uatServerCoreUrl),
class AppConfig extends InheritedWidget {
const AppConfig({
Key? key,
required this.appName,
required this.flavorName,
required this.apiBaseUrl,
required this.coreAppBaseUrl,
required Widget child,
}) : super(child: child);
class StringHelper {
static String removeAllHtmlTags(String htmlText) {
final RegExp exp = RegExp("<[^>]*>", multiLine: true);
return htmlText.replaceAll(exp, '');
}
static String shrinkSecondName(String? name) {
if (name != null && name.isNotEmpty) {
final nameStr = name.split(' ');
@JEuler
JEuler / extensions.dart
Created September 22, 2021 17:10
Extension class to convert between Web and DB entities
extension UserExtension on User {
DBUser getDbVersion() =>
DBUser(id, avatar ?? "", email ?? "", language ?? "", name ?? "");
}
import json
import stringcase
from xml.dom import minidom
xmldoc = minidom.parse('strings.xml')
itemlist = xmldoc.getElementsByTagName('string')
with open('strings.json', 'w', encoding='utf8') as out_file:
out_file.write('{')
for s in itemlist:
@JEuler
JEuler / circle_button.dart
Last active April 23, 2020 07:21
Button with a circle shape
import 'package:flutter/material.dart';
/// Button that have a circle shape
class CircleButton extends StatelessWidget {
// ignore: public_member_api_docs
const CircleButton(
{Key key,
this.onTap,
this.child,
this.size,
@JEuler
JEuler / user_store.dart
Created April 1, 2020 16:28
MobX Flutter store example
part 'user_store.g.dart';
/// User Store
class UserStore = UserStoreBase with _$UserStore;
/// User Store
abstract class UserStoreBase with Store {
final WebService _webService;
final StorageService _storageService;